Skip to content

Commit 876767e

Browse files
committed
[BUILD] switched from CMAKE_FIND_ROOT_PATH to CMAKE_PREFIX_PATH as it is the preferred way for giving additional base-directories for find_package
1 parent 86690f9 commit 876767e

File tree

1 file changed

+8
-27
lines changed

1 file changed

+8
-27
lines changed

cmake/setup_lib_find_paths.cmake

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -38,41 +38,22 @@
3838
# actual libraries are found in the CMake files of the individual componenents.
3939
#------------------------------------------------------------------------------
4040

41-
set(CONTRIB_CUSTOM_DIR CACHE DOC "DEPRECATED: Please use CMAKE_FIND_ROOT_PATH instead! User defined location of contrib dir. If left empty we assume the contrib to be in OpenMS/contrib!")
42-
set(CONTRIB_DIR ${OPENMS_HOST_DIRECTORY}/contrib/ CACHE INTERNAL "Final contrib path after looking at CMAKE_FIND_ROOT_PATH. Defaults to OpenMS/contrib")
43-
44-
if("${CMAKE_FIND_ROOT_PATH}" STREQUAL "")
45-
if(NOT "${CONTRIB_CUSTOM_DIR}" STREQUAL "")
46-
message("Please do no longer use -DCONTRIB_CUSTOM_DIR. This option is deprecated. Please use -DCMAKE_FIND_ROOT_PATH instead.")
47-
list(INSERT CONTRIB_DIR 0 ${CONTRIB_CUSTOM_DIR})
48-
else()
49-
# Append a few unusual default search directories for convenience
50-
# if no FIND ROOT PATH was specified.
51-
list(APPEND CONTRIB_DIR /opt/local /usr/local /usr)
52-
endif()
41+
if(NOT "${CMAKE_FIND_ROOT_PATH}" STREQUAL "" AND "${CMAKE_PREFIX_PATH}" STREQUAL "")
42+
set(CMAKE_PREFIX_PATH "${CMAKE_FIND_ROOT_PATH}")
43+
message(STATUS "Please switch to CMAKE_PREFIX_PATH CMAKE_FIND_ROOT_PATH ")
5344
endif()
5445

55-
#------------------------------------------------------------------------------
56-
# Append all contrib dirs to the (potentially empty) FIND_ROOT_PATH.
57-
# This will be the final search order used by regular CMAKE modules (by default)
58-
# and by the OpenMS macros (via CONTRIB_DIR).
59-
list(APPEND CMAKE_FIND_ROOT_PATH "${CONTRIB_DIR}")
60-
set(TMP "")
61-
foreach(CUSTOM_PATH ${CMAKE_FIND_ROOT_PATH})
62-
get_filename_component(ABS_PATH ${CUSTOM_PATH} ABSOLUTE)
63-
list(APPEND TMP ${ABS_PATH})
64-
endforeach()
65-
set(CMAKE_FIND_ROOT_PATH "${TMP}")
66-
set(CONTRIB_DIR "${CMAKE_FIND_ROOT_PATH}")
67-
46+
list(APPEND CMAKE_PREFIX_PATH ${OPENMS_HOST_DIRECTORY}/contrib/)
47+
# TODO: remove as soon as all libraries where switched to proper find modules
6848
set(CONTRIB_INCLUDE_DIR "" CACHE INTERNAL "contrib include dir")
6949
set(CONTRIB_LIB_DIR "" CACHE INTERNAL "contrib lib dir")
70-
foreach(CONTRIB_PATH ${CONTRIB_DIR})
50+
foreach(CONTRIB_PATH ${CMAKE_PREFIX_PATH})
7151
list(APPEND CONTRIB_INCLUDE_DIR "${CONTRIB_PATH}/include/")
7252
list(APPEND CONTRIB_LIB_DIR "${CONTRIB_PATH}/lib/")
7353
endforeach()
54+
7455
message(STATUS "===========================================================================")
75-
message(STATUS "CMake find root path: ${CMAKE_FIND_ROOT_PATH}")
56+
message(STATUS "CMake prefix path: ${CMAKE_PREFIX_PATH}")
7657
message(STATUS "Contrib search directories: ${CONTRIB_DIR}")
7758
message(STATUS "Contrib library directories: ${CONTRIB_LIB_DIR}")
7859
message(STATUS "Contrib include directories: ${CONTRIB_INCLUDE_DIR}")

0 commit comments

Comments
 (0)