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.
This commit is contained in:
Johann Dreo 2019-09-29 21:14:30 +02:00
commit d83681d6fa
12 changed files with 61 additions and 31 deletions

View file

@ -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)

View file

@ -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()

View file

@ -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}")

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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)

View file

@ -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)

View file

@ -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)
######################################################################################

View file

@ -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

View file

@ -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