Skip to content

Commit

Permalink
factored out configure_dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
drexlerd committed Jan 12, 2024
1 parent ae0161f commit dbfccec
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 50 deletions.
44 changes: 16 additions & 28 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
STRING "Choose the type of build." FORCE)
endif()

# make cache variables for install destinations
include(GNUInstallDirs)

option(ENABLE_TESTING "Enables compilation of tests." OFF)
if (ENABLE_TESTING)
message("Testing enabled.")
Expand All @@ -43,47 +46,32 @@ else()
endif()


##############################################################
# Dependency handling
##############################################################

# We installed the dependencies into the subdirectories under the install prefix.
# Hence must append them to the single cmake_prefix_path.
message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
list(LENGTH CMAKE_PREFIX_PATH PREFIX_PATH_COUNT)
if(PREFIX_PATH_COUNT GREATER 1)
message(FATAL_ERROR "Only one prefix path is allowed. Found multiple paths in CMAKE_PREFIX_PATH. Please add dependencies to the CMake Superbuild.")
endif()

list(APPEND MODIFIED_CMAKE_PREFIX_PATH
"${CMAKE_PREFIX_PATH}/benchmark"
"${CMAKE_PREFIX_PATH}/boost"
"${CMAKE_PREFIX_PATH}/googletest")
message(${MODIFIED_CMAKE_PREFIX_PATH})
set(CMAKE_PREFIX_PATH ${MODIFIED_CMAKE_PREFIX_PATH})
message(STATUS "MODIFIED_CMAKE_PREFIX_PATH:")
foreach(CMAKE_PREFIX_PATH_ARG ${CMAKE_PREFIX_PATH})
message(STATUS "-- ${CMAKE_PREFIX_PATH_ARG}")
endforeach()
# set(CMAKE_FIND_DEBUG_MODE ON)


##############################################################
# CMake modules and macro files
##############################################################

# make cache variables for install destinations
include(GNUInstallDirs)

list(APPEND CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/cmake"
)
include("configure_dependencies")
include("configure_boost")
include("configure_ccache")


##############################################################
# CCache
##############################################################

configure_ccache()


##############################################################
# Dependency Handling
##############################################################

# Add lokis dependencies
configure_dependencies()

# Boost
# Find Boost headers only according to https://cmake.org/cmake/help/latest/module/FindBoost.html
configure_boost()
Expand Down
40 changes: 18 additions & 22 deletions Config.cmake.in
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/cmake/configure_boost.cmake")
##############################################################
# CMake modules and macro files
##############################################################

##############
# Dependencies
##############
list(APPEND CMAKE_MODULE_PATH
"${PROJECT_SOURCE_DIR}/cmake"
)
include("configure_dependencies")
include("configure_boost")
include("configure_ccache")

message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
list(LENGTH CMAKE_PREFIX_PATH PREFIX_PATH_COUNT)
if(PREFIX_PATH_COUNT GREATER 1)
message(FATAL_ERROR "Only one prefix path is allowed. Found multiple paths in CMAKE_PREFIX_PATH. Please add dependencies to the CMake Superbuild.")
endif()

list(APPEND MODIFIED_CMAKE_PREFIX_PATH
"${CMAKE_PREFIX_PATH}/benchmark"
"${CMAKE_PREFIX_PATH}/boost"
"${CMAKE_PREFIX_PATH}/googletest")
message(${MODIFIED_CMAKE_PREFIX_PATH})
set(CMAKE_PREFIX_PATH ${MODIFIED_CMAKE_PREFIX_PATH})
message(STATUS "MODIFIED_CMAKE_PREFIX_PATH:")
foreach(CMAKE_PREFIX_PATH_ARG ${CMAKE_PREFIX_PATH})
message(STATUS "-- ${CMAKE_PREFIX_PATH_ARG}")
endforeach()
##############################################################
# Dependency Handling
##############################################################

include(CMakeFindDependencyMacro)
# Add lokis dependencies
configure_dependencies()

# Boost
# Find Boost headers only according to https://cmake.org/cmake/help/latest/module/FindBoost.html
configure_boost()
find_dependency(Boost ${BOOST_MIN_VERSION} REQUIRED)
find_package(Boost ${BOOST_MIN_VERSION} REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
endif()
Expand All @@ -47,4 +43,4 @@ foreach(_comp ${loki_FIND_COMPONENTS})
endforeach()

get_filename_component(LOKI_CONFIG_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
message(STATUS "Found loki: ${LOKI_CONFIG_DIR} (found version \"${loki_VERSION}\")")
message(STATUS "Found loki: ${LOKI_CONFIG_DIR} (found version \"${loki_VERSION}\")")
21 changes: 21 additions & 0 deletions cmake/configure_dependencies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
macro(configure_dependencies)
# We installed the dependencies into the subdirectories under the install prefix.
# Hence must append them to the single cmake_prefix_path.
message(STATUS "CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}")
list(LENGTH CMAKE_PREFIX_PATH PREFIX_PATH_COUNT)
if(PREFIX_PATH_COUNT GREATER 1)
message(FATAL_ERROR "Only one prefix path is allowed. Found multiple paths in CMAKE_PREFIX_PATH. Please add dependencies to the CMake Superbuild.")
endif()

list(APPEND MODIFIED_CMAKE_PREFIX_PATH
"${CMAKE_PREFIX_PATH}/benchmark"
"${CMAKE_PREFIX_PATH}/boost"
"${CMAKE_PREFIX_PATH}/googletest")
message(${MODIFIED_CMAKE_PREFIX_PATH})
set(CMAKE_PREFIX_PATH ${MODIFIED_CMAKE_PREFIX_PATH})
message(STATUS "MODIFIED_CMAKE_PREFIX_PATH:")
foreach(CMAKE_PREFIX_PATH_ARG ${CMAKE_PREFIX_PATH})
message(STATUS "-- ${CMAKE_PREFIX_PATH_ARG}")
endforeach()
# set(CMAKE_FIND_DEBUG_MODE ON)
endmacro()

0 comments on commit dbfccec

Please sign in to comment.