Files
uLib/uLibConfig.cmake.in
2025-09-05 18:04:54 +02:00

93 lines
2.9 KiB
CMake

# - Config file for the ULib package
# It defines the following variables
# ULIB_INCLUDE_DIRS - include directories for ULib
# ULIB_LIBRARIES - libraries to link against
# ULIB_EXECUTABLE - the bar executable
set(ULIB_VERSION @PROJECT_VERSION@)
@PACKAGE_INIT@
# Defines the include directories for the header files
# PACKAGE_INCLUDE_INSTALL_DIR is replaced by configure_package_config_file
# with the correct path for the installation.
set(ULIB_INCLUDE_DIRS "${PACKAGE_INCLUDE_INSTALL_DIR}")
get_filename_component(ULIB_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
# Search for the directory of exported build targets
set(uLib_BUILD_TARGETS_FILE
"${ULIB_CMAKE_DIR}/uLibTargets-build.cmake"
)
# Search for the directory of installed targets
set(uLib_INSTALL_TARGETS_FILE
"${ULIB_CMAKE_DIR}/uLibTargets.cmake"
)
# We use a logic based on the presence of the build target file
# to determine if we are in a local build.
if(EXISTS "${uLib_BUILD_TARGETS_FILE}")
message(STATUS " ++ Using uLib build targets")
include("${uLib_BUILD_TARGETS_FILE}")
set_and_check(ULIB_INCLUDE_DIRS "@ULIB_SOURCE_DIR@/src")
set_and_check(ULIB_LIBRARY_DIRS "${ULIB_CMAKE_DIR}")
set(ULIB_BUILD_DIR ${ULIB_CMAKE_DIR})
# Target that builds uLib inside its build directory
add_custom_target(uLib_dependency_target
COMMAND echo " --------------------------------- "
COMMAND echo " - Building uLib as a dependency - "
COMMAND echo " --------------------------------- "
COMMAND echo ""
COMMAND ${CMAKE_COMMAND} --build ${ULIB_BUILD_DIR}
COMMAND echo ""
WORKING_DIRECTORY ${ULIB_BUILD_DIR}
)
add_library(uLib_dependency INTERFACE)
add_dependencies(uLib_dependency uLib_dependency_target)
link_libraries(uLib_dependency)
else()
message(STATUS " ++ Using uLib installed targets")
include("${uLib_INSTALL_TARGETS_FILE}")
set_and_check(ULIB_INCLUDE_DIRS "@PACKAGE_INSTALL_INC_DIR@")
set(ULIB_SYSCONFIG_DIR "@PACKAGE_INSTALL_ETC_DIR@")
set_and_check(ULIB_CMAKE_DIR "@PACKAGE_INSTALL_CMAKE_DIR@")
set_and_check(ULIB_LIBRARY_DIRS "@PACKAGE_INSTALL_LIB_DIR@")
endif()
# --- Add required packages from uLib ---
# TODO: this should be selected if components are active
#
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost 1.45.0 COMPONENTS program_options filesystem REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
link_libraries(${Boost_LIBRARIES})
find_package(Eigen3 CONFIG REQUIRED)
include(${EIGEN3_USE_FILE})
find_package(ROOT CONFIG REQUIRED)
include(${ROOT_USE_FILE})
find_package(VTK REQUIRED)
# include(${VTK_USE_FILE})
link_directories("${ULIB_LIBRARY_DIRS}")
set(ULIB_LIBRARIES "@ULIB_SHARED_LIBRARIES@")
check_required_components(uLib)
# Set the variable to indicate that the package has been found.
set(uLib_FOUND TRUE)