Skip to content

Commit

Permalink
Append cmake subdir to CMAKE_MODULE_PATH
Browse files Browse the repository at this point in the history
It is important to append our own cmake module directory
to the project wide CMAKE_MODULE_PATH.
Normally CMAKE_MODULE_PATH is empty when project is started
because the default module path is hard coded,
e.g. /usr/share/cmake/Modules. But if this project is included
into another project, the surrounding project might want to
override how we find_package() our dependendies.

Changed "${CMAKE_CURRENT_SOURCE_DIR}" to "${CMAKE_CURRENT_LIST_DIR}"
because while current source can change, the cmake sub directory
will always stay adjacent to this CMakeLists.txt file.

Signed-off-by: Mikko Johannes Koivunalho <[email protected]>
  • Loading branch information
mikkoi committed Oct 26, 2019
1 parent 7a59392 commit 86cb492
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ project(UNIXem
LANGUAGES C CXX)

# Directory for CMake specific extensions and source files.
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")

# Set build type to Debug if this is a Git repository.
# Otherwise set to Release.
Expand Down Expand Up @@ -76,7 +76,7 @@ include(CMakePackageConfigHelpers)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/${EXPORT_NAME}-config.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/cmake/${EXPORT_NAME}-config.cmake
INSTALL_DESTINATION ${LIB_INSTALL_DIR}/${EXPORT_NAME}/cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/${EXPORT_NAME}/cmake
)
write_basic_package_version_file(
${CMAKE_CURRENT_BINARY_DIR}/cmake/${EXPORT_NAME}-config-version.cmake
Expand Down

0 comments on commit 86cb492

Please sign in to comment.