From d83681d6facb0c504af15dd2ef83a0cd90e8f32e Mon Sep 17 00:00:00 2001 From: nojhan Date: Sun, 29 Sep 2019 21:14:30 +0200 Subject: [PATCH] add cmake export to all targets & bugfix Find module - Add "EXPORT paradiseo-targets" to cmake's "install" commands. - Export those targets in "paradiseo-config.cmake", which is needed by FindParadiseo.cmake script. - Bugfix "FindParadiseo.cmake" script: - document PARADISEO_ROOT input, - add PARADISEO_DIR to specify a bin dir (try build, debug and release as defaults), - bugfix bad copy pastes involving edo and peo, - default messages only for eo, mo and meo. --- CMakeLists.txt | 9 +++++ cmake/module/FindParadiseo.cmake | 61 +++++++++++++++++++++----------- edo/src/utils/CMakeLists.txt | 2 +- eo/src/CMakeLists.txt | 2 +- eo/src/es/CMakeLists.txt | 4 +-- eo/src/ga/CMakeLists.txt | 2 +- eo/src/mpi/CMakeLists.txt | 2 +- eo/src/pyeo/CMakeLists.txt | 2 +- eo/src/serial/CMakeLists.txt | 2 +- eo/src/utils/CMakeLists.txt | 2 +- moeo/src/CMakeLists.txt | 2 +- smp/src/CMakeLists.txt | 2 +- 12 files changed, 61 insertions(+), 31 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3bbb8de3e..8bb3a2c4e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -137,3 +137,12 @@ endif() if("${CMAKE_BUILD_TYPE}" STREQUAL "Release") include(${CMAKE_CURRENT_SOURCE_DIR}/cmake/Package.cmake) endif() + + +# Add all targets to the build-tree export set +export(TARGETS eo FILE "${PROJECT_BINARY_DIR}/paradiseo-config.cmake") + +# Export the package for use from the build-tree +# (this registers the build-tree with a global CMake-registry) +export(PACKAGE paradiseo) + diff --git a/cmake/module/FindParadiseo.cmake b/cmake/module/FindParadiseo.cmake index 59b85a864..ecbd9ab79 100644 --- a/cmake/module/FindParadiseo.cmake +++ b/cmake/module/FindParadiseo.cmake @@ -1,3 +1,6 @@ +# The script use the following variables as search paths, if they are defined: +# - PARADISEO_ROOT : the project root +# - PARADISEO_DIR : the build/install directory with libraries binaries # # The following variables are filled out: # - PARADISEO_INCLUDE_DIR : EO, MO and MOEO source dir @@ -36,15 +39,21 @@ if(UNIX) set(INSTALL_SUB_DIR /paradiseo) endif() +if(PARADISEO_DIR) + # CMake config module is case sensitive + set(Paradiseo_DIR ${PARADISEO_DIR}) +endif() + # enabled components -if ("${Paradiseo_FIND_COMPONENTS}" STREQUAL "") +if (Paradiseo_FIND_COMPONENTS STREQUAL "") set(PARADISEO_LIBRARIES_TO_FIND eo eoutils cma es flowshop ga moeo) else() set(PARADISEO_LIBRARIES_TO_FIND ${Paradiseo_FIND_COMPONENTS}) endif() +message(STATUS "${PARADISEO_LIBRARIES_TO_FIND}") #set the build directory -set(BUILD_DIR build) +#set(BUILD_DIR build) # Path set(PARADISEO_SRC_PATHS @@ -72,32 +81,36 @@ find_path(MOEO_INCLUDE_DIR moeo PATH_SUFFIXES include${INSTALL_SUB_DIR}/moeo moeo/src PATHS ${PARADISEO_SRC_PATHS}) -# Specific for SMP and PEO +set(PARADISEO_INCLUDE_DIR ${EO_INCLUDE_DIR} ${MO_INCLUDE_DIR} ${MOEO_INCLUDE_DIR}) + +# Specific for SMP, EDO and PEO foreach(COMP ${PARADISEO_LIBRARIES_TO_FIND}) if(${COMP} STREQUAL "smp") set(SMP_FOUND true) find_path(SMP_INCLUDE_DIR smp PATH_SUFFIXES include${INSTALL_SUB_DIR}/smp smp/src PATHS ${PARADISEO_SRC_PATHS}) - elseif(${COMP} STREQUAL "peo") - set(PEO_FOUND true) + elseif(${COMP} STREQUAL "edo") + set(EDO_FOUND true) find_path(EDO_INCLUDE_DIR edo PATH_SUFFIXES include${INSTALL_SUB_DIR}/edo edo/src PATHS ${PARADISEO_SRC_PATHS}) - elseif(${COMP} STREQUAL "edo") - set(EDO_FOUND true) - find_path(EDO_INCLUDE_DIR peo + elseif(${COMP} STREQUAL "peo") + set(PEO_FOUND true) + find_path(PEO_INCLUDE_DIR peo PATH_SUFFIXES include${INSTALL_SUB_DIR}/peo peo/src PATHS ${PARADISEO_SRC_PATHS}) endif() endforeach() -set(PARADISEO_INCLUDE_DIR ${EO_INCLUDE_DIR} ${EDO_INCLUDE_DIR} ${MO_INCLUDE_DIR} ${MOEO_INCLUDE_DIR}) - if(SMP_FOUND) set(PARADISEO_INCLUDE_DIR ${PARADISEO_INCLUDE_DIR} ${SMP_INCLUDE_DIR}) endif() +if(EDO_FOUND) + set(PARADISEO_INCLUDE_DIR ${PARADISEO_INCLUDE_DIR} ${EDO_INCLUDE_DIR}) +endif() + if(PEO_FOUND) set(PARADISEO_INCLUDE_DIR ${PARADISEO_INCLUDE_DIR} ${PEO_INCLUDE_DIR}) endif() @@ -106,8 +119,14 @@ endif() set(PARADISEO_FOUND true) # will be set to false if one of the required modules is not found set(FIND_PARADISEO_LIB_PATHS - ${PARADISEO_ROOT}/${BUILD_DIR} - $ENV{PARADISEO_ROOT} + # ${PARADISEO_ROOT}/${BUILD_DIR} + ${Paradiseo_DIR} + $ENV{PARADISEO_ROOT}/build + $ENV{PARADISEO_ROOT}/release + $ENV{PARADISEO_ROOT}/debug + ${PARADISEO_ROOT}/build + ${PARADISEO_ROOT}/release + ${PARADISEO_ROOT}/debug /usr/local/ /usr/ /sw # Fink @@ -153,18 +172,20 @@ endforeach() # handle result if(PARADISEO_FOUND) - message(STATUS "Found ParadisEO includes :") - message(${EO_INCLUDE_DIR}) - message(${EDO_INCLUDE_DIR}) - message(${MO_INCLUDE_DIR}) - message(${MOEO_INCLUDE_DIR}) + message(STATUS "Found the following ParadisEO include directories:") + message(STATUS "\tEO\t: " ${EO_INCLUDE_DIR}) + message(STATUS "\tMO\t: " ${MO_INCLUDE_DIR}) + message(STATUS "\tMOEO\t: " ${MOEO_INCLUDE_DIR}) if(SMP_FOUND) - message(${SMP_INCLUDE_DIR}) + message(STATUS "\tSMP\t: " ${SMP_INCLUDE_DIR}) + endif() + if(EDO_FOUND) + message(STATUS "\tEDO\t: " ${EDO_INCLUDE_DIR}) endif() if(PEO_FOUND) - message(${PEO_INCLUDE_DIR}) + message(STATUS "\tPEO\t: " ${PEO_INCLUDE_DIR}) endif() else() # include directory or library not found - message(FATAL_ERROR "Could NOT find ParadisEO (missing : ${FIND_PARADISEO_MISSING})") + message(FATAL_ERROR "Could NOT find ParadisEO (missing \t: ${FIND_PARADISEO_MISSING})") endif() diff --git a/edo/src/utils/CMakeLists.txt b/edo/src/utils/CMakeLists.txt index a6fc4d067..01c928a66 100644 --- a/edo/src/utils/CMakeLists.txt +++ b/edo/src/utils/CMakeLists.txt @@ -14,7 +14,7 @@ set(LIBRARY_OUTPUT_PATH ${EDOUTILS_LIB_OUTPUT_PATH}) file(GLOB SOURCES *.cpp) add_library(edoutils ${SOURCES}) -install(TARGETS edoutils ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS edoutils EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) set(EDOUTILS_VERSION ${GLOBAL_VERSION}) set_target_properties(edoutils PROPERTIES VERSION "${EDOUTILS_VERSION}") diff --git a/eo/src/CMakeLists.txt b/eo/src/CMakeLists.txt index b2b445a93..76f26deae 100644 --- a/eo/src/CMakeLists.txt +++ b/eo/src/CMakeLists.txt @@ -29,7 +29,7 @@ add_library(eo STATIC ${EO_SOURCES}) set(EO_VERSION ${GLOBAL_VERSION}) set_target_properties(eo PROPERTIES VERSION "${EO_VERSION}") -install(TARGETS eo ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS eo EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) file(GLOB HDRS *.h eo) install(FILES ${HDRS} DESTINATION include${INSTALL_SUB_DIR}/eo COMPONENT headers) diff --git a/eo/src/es/CMakeLists.txt b/eo/src/es/CMakeLists.txt index 15a7f9f3b..55de761eb 100644 --- a/eo/src/es/CMakeLists.txt +++ b/eo/src/es/CMakeLists.txt @@ -38,10 +38,10 @@ set(CMA_SOURCES ) add_library(es STATIC ${ES_SOURCES}) -install(TARGETS es ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS es EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) add_library(cma STATIC ${CMA_SOURCES}) -install(TARGETS cma ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS cma EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) ###################################################################################### ### 3) Optionnal diff --git a/eo/src/ga/CMakeLists.txt b/eo/src/ga/CMakeLists.txt index 1a1cd656d..c03deed66 100644 --- a/eo/src/ga/CMakeLists.txt +++ b/eo/src/ga/CMakeLists.txt @@ -23,7 +23,7 @@ set(GA_SOURCES ) add_library(ga STATIC ${GA_SOURCES}) -install(TARGETS ga ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS ga EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) ###################################################################################### ### 3) Optionnal diff --git a/eo/src/mpi/CMakeLists.txt b/eo/src/mpi/CMakeLists.txt index ebf16335a..2c4eaf149 100644 --- a/eo/src/mpi/CMakeLists.txt +++ b/eo/src/mpi/CMakeLists.txt @@ -20,7 +20,7 @@ set(EOMPI_SOURCES ) add_library(eompi STATIC ${EOMPI_SOURCES}) -install(TARGETS eompi ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS eompi EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) file(GLOB HDRS *.h) install(FILES ${HDRS} DESTINATION include${INSTALL_SUB_DIR}/eo/mpi COMPONENT headers) diff --git a/eo/src/pyeo/CMakeLists.txt b/eo/src/pyeo/CMakeLists.txt index a8f6c8d54..3e057d924 100644 --- a/eo/src/pyeo/CMakeLists.txt +++ b/eo/src/pyeo/CMakeLists.txt @@ -48,7 +48,7 @@ set(EO_SOURCES # shared library add_library(PyEO MODULE ${SOURCES} ${EO_SOURCES}) -install(TARGETS PyEO LIBRARY DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS PyEO EXPORT paradiseo-targets LIBRARY DESTINATION ${LIB} COMPONENT libraries) # python 2.5 must have pyd if(WIN32 AND NOT CYGWIN) diff --git a/eo/src/serial/CMakeLists.txt b/eo/src/serial/CMakeLists.txt index d7a6fb574..a1f3578a8 100644 --- a/eo/src/serial/CMakeLists.txt +++ b/eo/src/serial/CMakeLists.txt @@ -20,7 +20,7 @@ set(EOSERIAL_SOURCES ) add_library(eoserial STATIC ${EOSERIAL_SOURCES}) -install(TARGETS eoserial ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS eoserial EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) file(GLOB HDRS *.h) install(FILES ${HDRS} DESTINATION include${INSTALL_SUB_DIR}/eo/serial COMPONENT headers) diff --git a/eo/src/utils/CMakeLists.txt b/eo/src/utils/CMakeLists.txt index 8e927dd4f..649344b0e 100644 --- a/eo/src/utils/CMakeLists.txt +++ b/eo/src/utils/CMakeLists.txt @@ -33,7 +33,7 @@ set(EOUTILS_SOURCES ) add_library(eoutils STATIC ${EOUTILS_SOURCES}) -install(TARGETS eoutils ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS eoutils EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) ###################################################################################### diff --git a/moeo/src/CMakeLists.txt b/moeo/src/CMakeLists.txt index a696cdbb5..c06351346 100644 --- a/moeo/src/CMakeLists.txt +++ b/moeo/src/CMakeLists.txt @@ -23,7 +23,7 @@ add_library(moeo STATIC ${MOEO_CORE}) set(MOEO_VERSION ${GLOBAL_VERSION}) set_target_properties(moeo PROPERTIES VERSION "${MOEO_VERSION}") -install(TARGETS moeo ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS moeo EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) ###################################################################################### ### 3) Look for headers diff --git a/smp/src/CMakeLists.txt b/smp/src/CMakeLists.txt index 07cde8272..d8568f97d 100644 --- a/smp/src/CMakeLists.txt +++ b/smp/src/CMakeLists.txt @@ -37,7 +37,7 @@ set (SMP_FILE add_library(smp STATIC ${SMP_FILE}) -install(TARGETS smp ARCHIVE DESTINATION ${LIB} COMPONENT libraries) +install(TARGETS smp EXPORT paradiseo-targets ARCHIVE DESTINATION ${LIB} COMPONENT libraries) ###################################################################################### ### 3) Look for headers