Skip to content

Commit

Permalink
Distribute FindFoo.cmake files
Browse files Browse the repository at this point in the history
In the build tree into: `PROJECT_BINARY_DIR/Modules`
In install tree into `DGTAL_CMAKE_DIR_INSTALL/Modules`

Also change find_dependency to find_package for the FindFoo.cmake packages.
It seems that find_dependency prioritizes Config files and ignore
Find modules.
  • Loading branch information
phcerdan committed Oct 19, 2020
1 parent fc71fef commit 757a5b9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
14 changes: 8 additions & 6 deletions cmake/DGtalConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ set(DGTAL_VERSION "@DGTAL_VERSION@")

include(CMakeFindDependencyMacro)

get_filename_component(DGTAL_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${DGTAL_CMAKE_DIR}/Modules")

#### Required dependencies ####
find_dependency(Boost REQUIRED
@Boost_HINTS@
Expand All @@ -19,14 +22,14 @@ find_dependency(ZLIB REQUIRED
)

if(@GMP_FOUND_DGTAL@) #if GMP_FOUND_DGTAL
find_dependency(GMP REQUIRED
find_package(GMP REQUIRED
@GMP_HINTS@
)
set(WITH_GMP 1)
endif()

if(@MAGICK++_FOUND_DGTAL@) #if MAGICK++_FOUND_DGTAL
find_dependency(Magick REQUIRED
find_package(Magick REQUIRED
@Magick_HINTS@
)
set(WITH_MAGICK 1)
Expand All @@ -40,7 +43,7 @@ if(@ITK_FOUND_DGTAL@) #if ITK_FOUND_DGTAL
endif()

if(@CAIRO_FOUND_DGTAL@) #if CAIRO_FOUND_DGTAL
find_dependency(Cairo REQUIRED
find_package(Cairo REQUIRED
@Cairo_HINTS@
)
set(WITH_CAIRO 1)
Expand All @@ -54,7 +57,7 @@ if(@HDF5_FOUND_DGTAL@) #if HDF5_FOUND_DGTAL
endif()

if (@QGLVIEWER_FOUND_DGTAL@) #if QGLVIEWER_FOUND_DGTAL
find_dependency(QGLVIEWER REQUIRED
find_package(QGLVIEWER REQUIRED
@QGLVIEWER_HINTS@
)
set(WITH_VISU3D_QGLVIEWER 1)
Expand Down Expand Up @@ -106,13 +109,12 @@ if(@CGAL_FOUND_DGTAL@) #if CGAL_FOUND_DGTAL
endif()

if(@FFTW3_FOUND_DGTAL@) #if FFTW3_FOUND_DGTAL
find_dependency(FFTW3 REQUIRED
find_package(FFTW3 REQUIRED
@FFTW3_HINTS@
)
set(WITH_FFTW3 1)
endif()

get_filename_component(DGTAL_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
if(NOT TARGET DGtal)
# Our imported targets, including dependencies
include ("${DGTAL_CMAKE_DIR}/DGtalLibraryDepends.cmake")
Expand Down
13 changes: 13 additions & 0 deletions cmake/DGtalConfigGenerator.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,16 @@ install(FILES
"${PROJECT_BINARY_DIR}/InstallFiles/DGtalConfig.cmake"
"${PROJECT_BINARY_DIR}/InstallFiles/DGtalConfigVersion.cmake"
DESTINATION "${DGTAL_CMAKE_DIR_INSTALL}" COMPONENT dev)

# Distribute FindFoo.cmake files to the build and install tree
set(_find_cmake_files
"${PROJECT_SOURCE_DIR}/cmake/FindCairo.cmake"
"${PROJECT_SOURCE_DIR}/cmake/FindFFTW3.cmake"
"${PROJECT_SOURCE_DIR}/cmake/FindMagick.cmake"
"${PROJECT_SOURCE_DIR}/cmake/FindQGLVIEWER.cmake"
"${PROJECT_SOURCE_DIR}/cmake/FindGMP.cmake"
)
file(COPY ${_find_cmake_files}
DESTINATION "${PROJECT_BINARY_DIR}/Modules")
install(FILES ${_find_cmake_files}
DESTINATION "${DGTAL_CMAKE_DIR_INSTALL}/Modules" COMPONENT dev)

0 comments on commit 757a5b9

Please sign in to comment.