Commit 7bc1bda6 authored by Alexis Girault's avatar Alexis Girault

COMP: find VegaFEMConfig & Threads/PThreads

With the former commit that fixes the wrongfully
exported VegaFEM, VegaFEM was not found anymore
by iMSTK. This is because its Config.cmake file
was not configured in VegaFEM_DIR aka the top-level
of VegaFEM build directory.

This commit:
- correctly places the config & target files
- removes the exports(TARGETS ...) for Vega modules
- corrects the finding of the pthreads package if needed
parent d1ab0858
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
find_package(PThreads REQUIRED)
list(REMOVE_ITEM CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
# Add access to dependencies Find<package>.cmake files
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/CMake)
include("${CMAKE_CURRENT_LIST_DIR}/VegaFEMTargets.cmake")
\ No newline at end of file
set(VegaFEM_ENABLE_PTHREADS_SUPPORT @VegaFEM_ENABLE_PTHREADS_SUPPORT@)
if(VegaFEM_ENABLE_PTHREADS_SUPPORT)
if(WIN32)
find_package(PThreads REQUIRED)
else()
find_package(Threads REQUIRED)
endif()
endif()
# Remove access to those dependencies
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/CMake)
include("${CMAKE_CURRENT_LIST_DIR}/VegaFEMTargets.cmake")
......@@ -10,8 +10,6 @@ function(vega_install_library target)
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include
)
export(PACKAGE ${target})
export(TARGETS ${target} ${target_DEPENDS} APPEND FILE ${target}-exports.cmake)
endfunction()
function(vega_add_library target)
......@@ -38,7 +36,7 @@ function(vega_add_library target)
vega_install_library(${target})
install(FILES ${target_PUBLIC_HEADERS}
DESTINATION include/vega/${target}
COMPONENT Development
COMPONENT Devel
)
endif()
endfunction()
......@@ -23,7 +23,6 @@ endif(COMMAND CMAKE_POLICY)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
include(CMakePackageConfigHelpers)
include(VegaFEMMacros)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE OFF)
......@@ -95,15 +94,14 @@ if(VegaFEM_ENABLE_PTHREADS_SUPPORT)
if(WIN32)
set(THREADS_USE_PTHREADS_WIN32 1)
find_package(PThreads REQUIRED)
configure_file(
CMake/FindPThreads.cmake
"${CMAKE_CURRENT_BINARY_DIR}/CMake/FindPThreads.cmake"
COPYONLY
)
else()
find_package(Threads REQUIRED)
endif()
configure_file(
CMake/FindPThreads.cmake
"${CMAKE_CURRENT_BINARY_DIR}/VegaFEM/FindPThreads.cmake"
COPYONLY
)
endif()
if (VegaFEM_BUILD_MODEL_REDUCTION)
......@@ -196,36 +194,35 @@ endif()
add_subdirectory(src)
export(TARGETS ${VegaFEM_Modules}
FILE "${CMAKE_CURRENT_BINARY_DIR}/VegaFEM/VegaFEMTargets.cmake"
NAMESPACE VegaFEM::
)
include(CMakePackageConfigHelpers)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/VegaFEM/VegaFEMConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/VegaFEMConfigVersion.cmake"
VERSION ${VegaFEM_VERSION}
COMPATIBILITY AnyNewerVersion
)
export(EXPORT VegaFEMTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/VegaFEMTargets.cmake"
NAMESPACE VegaFEM::
)
configure_file(
CMake/VegaFEMConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/VegaFEM/VegaFEMConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/VegaFEMConfig.cmake"
@ONLY
)
set(ConfigPackageLocation lib/cmake/VegaFEM)
install(EXPORT VegaFEMTargets
FILE
VegaFEMTargets.cmake
NAMESPACE VegaFEM::
DESTINATION
${ConfigPackageLocation}
FILE VegaFEMTargets.cmake
NAMESPACE VegaFEM::
DESTINATION ${ConfigPackageLocation}
)
install(
FILES
"${CMAKE_CURRENT_BINARY_DIR}/VegaFEM/VegaFEMConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/VegaFEM/VegaFEMConfigVersion.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/VegaFEMConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/VegaFEMConfigVersion.cmake"
DESTINATION
${ConfigPackageLocation}
COMPONENT
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment