From cbb7628473a089fe5fb9e43b4ca4bc5c9200196a Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Fri, 25 Mar 2022 22:31:56 -0300 Subject: [PATCH] build, docs: fixes find_external_library header search paths and docs Includes: - search for headers in the library directory when using find_external_library - prevent module processing (brite, click and openflow) from continuing if ${dependency_name}_FOUND is not set --- build-support/macros-and-definitions.cmake | 5 ++--- doc/manual/source/working-with-cmake.rst | 16 +++++++++++----- src/brite/CMakeLists.txt | 6 ++++-- src/click/CMakeLists.txt | 6 ++++-- src/openflow/CMakeLists.txt | 6 ++++-- 5 files changed, 25 insertions(+), 14 deletions(-) diff --git a/build-support/macros-and-definitions.cmake b/build-support/macros-and-definitions.cmake index 97afd16e6..6594320d5 100644 --- a/build-support/macros-and-definitions.cmake +++ b/build-support/macros-and-definitions.cmake @@ -1305,8 +1305,7 @@ function(remove_lib_prefix prefixed_library library) # If there is a lib prefix, try to remove it if(${lib_pos} EQUAL 0) - # Check if we still have something remaining - # after removing the "lib" prefix + # Check if we still have something remaining after removing the "lib" prefix string(LENGTH ${prefixed_library} len) if(${len} LESS 4) message(FATAL_ERROR "Invalid library name: ${prefixed_library}") @@ -1821,7 +1820,7 @@ function(find_external_library) foreach(libdir ${library_dirs}) get_filename_component(parent_libdir ${libdir} DIRECTORY) get_filename_component(parent_parent_libdir ${parent_libdir} DIRECTORY) - list(APPEND parent_dirs ${parent_libdir} ${parent_parent_libdir}) + list(APPEND parent_dirs ${libdir} ${parent_libdir} ${parent_parent_libdir}) endforeach() # If we already found a library somewhere, limit the search paths for the diff --git a/doc/manual/source/working-with-cmake.rst b/doc/manual/source/working-with-cmake.rst index f4ef67a16..93353bb36 100644 --- a/doc/manual/source/working-with-cmake.rst +++ b/doc/manual/source/working-with-cmake.rst @@ -814,7 +814,7 @@ Here is how it works: foreach(libdir ${library_dirs}) get_filename_component(parent_libdir ${libdir} DIRECTORY) get_filename_component(parent_parent_libdir ${parent_libdir} DIRECTORY) - list(APPEND parent_dirs ${parent_libdir} ${parent_parent_libdir}) + list(APPEND parent_dirs ${libdir} ${parent_libdir} ${parent_parent_libdir}) endforeach() # If we already found a library somewhere, limit the search paths for the header @@ -986,10 +986,16 @@ example of ``find_external_library`` usage. SEARCH_PATHS ${NS3_WITH_OPENFLOW} # user-settable search path, empty by default ) - # Check if header and library were found, - # and stop processing the module in case they were not - if(NOT - ${openflow_FOUND} + # Before testing if the header and library were found ${openflow_FOUND}, + # test if openflow_FOUND was defined + # If openflow_FOUND was not defined, the dependency name above doesn't match + # the tested values below + # If openflow_FOUND is set to FALSE, stop processing the module by returning + # to the parent directory with return() + if((NOT + openflow_FOUND) + AND (NOT + ${openflow_FOUND}) ) message(STATUS "Openflow was not found") return() diff --git a/src/brite/CMakeLists.txt b/src/brite/CMakeLists.txt index 6ae2b3364..c44985927 100644 --- a/src/brite/CMakeLists.txt +++ b/src/brite/CMakeLists.txt @@ -16,8 +16,10 @@ find_external_library( SEARCH_PATHS ${NS3_WITH_BRITE} ) -if(NOT - ${brite_FOUND} +if((NOT + brite_FOUND) + OR (NOT + ${brite_FOUND}) ) message(STATUS "Skipping src/brite") return() diff --git a/src/click/CMakeLists.txt b/src/click/CMakeLists.txt index 7346ac4be..7409033c7 100644 --- a/src/click/CMakeLists.txt +++ b/src/click/CMakeLists.txt @@ -17,8 +17,10 @@ find_external_library( SEARCH_PATHS ${NS3_WITH_CLICK} ) -if(NOT - ${click_FOUND} +if((NOT + click_FOUND) + AND (NOT + ${click_FOUND}) ) message(STATUS "Skipping src/click") return() diff --git a/src/openflow/CMakeLists.txt b/src/openflow/CMakeLists.txt index 71a3546eb..ccdb9ce16 100644 --- a/src/openflow/CMakeLists.txt +++ b/src/openflow/CMakeLists.txt @@ -16,8 +16,10 @@ find_external_library( SEARCH_PATHS ${NS3_WITH_OPENFLOW} ) -if(NOT - ${openflow_FOUND} +if((NOT + openflow_FOUND) + AND (NOT + ${openflow_FOUND}) ) message(STATUS "Skipping src/openflow") return()