From cbb0c0d7d532e49eb87b5773a9bc84f3746a0195 Mon Sep 17 00:00:00 2001 From: Anthony Scopatz Date: Thu, 19 Feb 2015 15:28:55 -0600 Subject: [PATCH] updated build sys --- cmake/CTestCustom.cmake | 2 +- cmake/FindCOIN.cmake | 154 ++++----- cmake/FindCyclus.cmake | 208 ++++++------ cmake/FindGlib.cmake | 42 +-- cmake/FindGlibmm.cmake | 23 +- cmake/FindHDF5.cmake | 382 +++++++++++----------- cmake/FindLibXML++.cmake | 24 +- cmake/FindSigC++.cmake | 23 +- cmake/FindSqlite3.cmake | 78 ++--- cmake/LibFindMacros.cmake | 153 +++++---- cmake/SelectLibraryConfigurations.cmake | 63 ++-- cmake/UseCyclus.cmake | 412 ++++++++++++------------ cmake/cmake_uninstall.cmake.in | 14 +- cmake/generate_test_macros.py | 32 +- install.py | 11 +- 15 files changed, 811 insertions(+), 810 deletions(-) diff --git a/cmake/CTestCustom.cmake b/cmake/CTestCustom.cmake index 2a1b423..3b003b6 100644 --- a/cmake/CTestCustom.cmake +++ b/cmake/CTestCustom.cmake @@ -1,3 +1,3 @@ ## uncomment this section when the following issue has been fixed by CMake ## http://permalink.gmane.org/gmane.comp.programming.tools.cmake.devel/5990 -# SET(CTEST_CUSTOM_POST_TEST "python ${CMAKE_CURRENT_LIST_DIR}/print_regs.py") \ No newline at end of file +# SET(CTEST_CUSTOM_POST_TEST "python ${CMAKE_CURRENT_LIST_DIR}/print_regs.py") diff --git a/cmake/FindCOIN.cmake b/cmake/FindCOIN.cmake index 0ee797d..29f6e07 100644 --- a/cmake/FindCOIN.cmake +++ b/cmake/FindCOIN.cmake @@ -4,7 +4,7 @@ # Last updated: 12/17/12 # This cmake file is designed to locate coin-related -# dependencies on a filesystem. +# dependencies on a filesystem. # # If the coin dependencies were installed in a non-standard # directory, e.g. installed from source perhaps, then @@ -33,17 +33,17 @@ MESSAGE(STATUS "COIN_ROOT_DIR hint is : ${COIN_ROOT_DIR}") # MESSAGE(STATUS "Coin multiple library dependency status:") FIND_PATH(COIN_INCLUDE_DIR coin/CbcModel.hpp - HINTS "${COIN_INCLUDE_DIR}" - HINTS "${COIN_ROOT_DIR}/include" - HINTS /usr/ - HINTS /usr/include/ - HINTS /usr/local/ - HINTS /usr/local/include/ - HINTS /usr/coin/ - HINTS /usr/coin-Cbc/ - HINTS /usr/local/coin/ - HINTS /usr/local/coin-Cbc/ -) + HINTS "${COIN_INCLUDE_DIR}" + HINTS "${COIN_ROOT_DIR}/include" + HINTS /usr/ + HINTS /usr/include/ + HINTS /usr/local/ + HINTS /usr/local/include/ + HINTS /usr/coin/ + HINTS /usr/coin-Cbc/ + HINTS /usr/local/coin/ + HINTS /usr/local/coin-Cbc/ + ) set(COIN_INCLUDE_DIR ${COIN_INCLUDE_DIR}/coin) MESSAGE("\tCOIN Include Dir: ${COIN_INCLUDE_DIR}") @@ -51,45 +51,45 @@ MESSAGE("\tCOIN Include Dir: ${COIN_INCLUDE_DIR}") # Find all coin library dependencies # FIND_LIBRARY(COIN_CBC_LIBRARY - NAMES Cbc libCbc #libCbc.so.0 - HINTS "${COIN_INCLUDE_DIR}/../../lib/" - HINTS "${COIN_ROOT_DIR}/lib" -) + NAMES Cbc libCbc #libCbc.so.0 + HINTS "${COIN_INCLUDE_DIR}/../../lib/" + HINTS "${COIN_ROOT_DIR}/lib" + ) MESSAGE("\tCOIN CBC: ${COIN_CBC_LIBRARY}") FIND_LIBRARY(COIN_CBC_SOLVER_LIBRARY - NAMES CbcSolver libCbcSolver libCbcSolver.so.0 - HINTS ${COIN_INCLUDE_DIR}/../../lib/ - HINTS "${COIN_ROOT_DIR}/lib" -) + NAMES CbcSolver libCbcSolver libCbcSolver.so.0 + HINTS ${COIN_INCLUDE_DIR}/../../lib/ + HINTS "${COIN_ROOT_DIR}/lib" + ) MESSAGE("\tCOIN CBC solver: ${COIN_CBC_SOLVER_LIBRARY}") FIND_LIBRARY(COIN_CGL_LIBRARY - NAMES Cgl libCgl libCgl.so.0 - HINTS ${COIN_INCLUDE_DIR}/../../lib/ - HINTS "${COIN_ROOT_DIR}/lib" -) + NAMES Cgl libCgl libCgl.so.0 + HINTS ${COIN_INCLUDE_DIR}/../../lib/ + HINTS "${COIN_ROOT_DIR}/lib" + ) MESSAGE("\tCOIN CGL: ${COIN_CGL_LIBRARY}") FIND_LIBRARY(COIN_CLP_LIBRARY - NAMES Clp libClp libClp.so.0 - HINTS ${COIN_INCLUDE_DIR}/../../lib/ - HINTS "${COIN_ROOT_DIR}/lib" -) + NAMES Clp libClp libClp.so.0 + HINTS ${COIN_INCLUDE_DIR}/../../lib/ + HINTS "${COIN_ROOT_DIR}/lib" + ) MESSAGE("\tCOIN CLP: ${COIN_CLP_LIBRARY}") FIND_LIBRARY(COIN_COIN_UTILS_LIBRARY - NAMES CoinUtils libCoinUtils libCoinUtils.so.0 - HINTS ${COIN_INCLUDE_DIR}/../../lib/ - HINTS "${COIN_ROOT_DIR}/lib" -) + NAMES CoinUtils libCoinUtils libCoinUtils.so.0 + HINTS ${COIN_INCLUDE_DIR}/../../lib/ + HINTS "${COIN_ROOT_DIR}/lib" + ) MESSAGE("\tCOIN UTILS: ${COIN_COIN_UTILS_LIBRARY}") FIND_LIBRARY(COIN_OSI_LIBRARY - NAMES Osi libOsi libOsi.so.0 - HINTS ${COIN_INCLUDE_DIR}/../../lib/ - HINTS "${COIN_ROOT_DIR}/lib" -) + NAMES Osi libOsi libOsi.so.0 + HINTS ${COIN_INCLUDE_DIR}/../../lib/ + HINTS "${COIN_ROOT_DIR}/lib" + ) MESSAGE("\tCOIN OSI: ${COIN_OSI_LIBRARY}") # FIND_LIBRARY(COIN_OSI_CBC_LIBRARY @@ -100,66 +100,66 @@ MESSAGE("\tCOIN OSI: ${COIN_OSI_LIBRARY}") # MESSAGE("\tCOIN OSI CBC: ${COIN_OSI_CBC_LIBRARY}") FIND_LIBRARY(COIN_OSI_CLP_LIBRARY - NAMES OsiClp libOsiClp libOsiClp.so.0 - HINTS ${COIN_INCLUDE_DIR}/../../lib/ - HINTS "${COIN_ROOT_DIR}/lib" -) + NAMES OsiClp libOsiClp libOsiClp.so.0 + HINTS ${COIN_INCLUDE_DIR}/../../lib/ + HINTS "${COIN_ROOT_DIR}/lib" + ) MESSAGE("\tCOIN OSI CLP: ${COIN_OSI_CLP_LIBRARY}") FIND_LIBRARY(COIN_ZLIB_LIBRARY - NAMES z libz libz.so.1 - HINTS ${COIN_ROOT_DIR}/lib - HINTS "${COIN_ROOT_DIR}/lib" -) + NAMES z libz libz.so.1 + HINTS ${COIN_ROOT_DIR}/lib + HINTS "${COIN_ROOT_DIR}/lib" + ) MESSAGE("\tCOIN ZLIB: ${COIN_ZLIB_LIBRARY}") FIND_LIBRARY(COIN_BZ2_LIBRARY - NAMES bz2 libz2 libz2.so.1 - HINTS ${COIN_ROOT_DIR}/lib - HINTS "${COIN_ROOT_DIR}/lib" -) + NAMES bz2 libz2 libz2.so.1 + HINTS ${COIN_ROOT_DIR}/lib + HINTS "${COIN_ROOT_DIR}/lib" + ) MESSAGE("\tCOIN BZ2: ${COIN_BZ2_LIBRARY}") - + INCLUDE(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(COIN DEFAULT_MSG - COIN_INCLUDE_DIR - COIN_CBC_LIBRARY - COIN_CBC_SOLVER_LIBRARY - COIN_CGL_LIBRARY - COIN_CLP_LIBRARY - COIN_COIN_UTILS_LIBRARY - COIN_OSI_LIBRARY -# Not required by cbc v2.5, but required by later versions -# COIN_OSI_CBC_LIBRARY - COIN_OSI_CLP_LIBRARY - COIN_ZLIB_LIBRARY - COIN_BZ2_LIBRARY -) + COIN_INCLUDE_DIR + COIN_CBC_LIBRARY + COIN_CBC_SOLVER_LIBRARY + COIN_CGL_LIBRARY + COIN_CLP_LIBRARY + COIN_COIN_UTILS_LIBRARY + COIN_OSI_LIBRARY + # Not required by cbc v2.5, but required by later versions + # COIN_OSI_CBC_LIBRARY + COIN_OSI_CLP_LIBRARY + COIN_ZLIB_LIBRARY + COIN_BZ2_LIBRARY + ) # # Set all required cmake variables based on our findings # IF(COIN_FOUND) - SET(COIN_INCLUDE_DIRS ${COIN_INCLUDE_DIR}) - SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARY};${COIN_COIN_UTILS_LIBRARY};${COIN_ZLIB_LIBRARY}") - IF(COIN_ZLIB_LIBRARY) - SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARIES};${COIN_ZLIB_LIBRARY}") - ENDIF(COIN_ZLIB_LIBRARY) - IF(COIN_BZ2_LIBRARY) - SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARIES};${COIN_BZ2_LIBRARY}") - ENDIF(COIN_BZ2_LIBRARY) -# Not required by cbc v2.5, but required by later versions in which case, -# the lower line should be commented out and this line used - #SET(COIN_CBC_LIBRARIES "${COIN_CBC_LIBRARY};${COIN_CBC_SOLVER_LIBRARY};${COIN_CGL_LIBRARY};${COIN_OSI_LIBRARY};${COIN_OSI_CBC_LIBRARY};${COIN_OSI_CLP_LIBRARY};${COIN_CLP_LIBRARIES}") - SET(COIN_CBC_LIBRARIES "${COIN_CBC_LIBRARY};${COIN_CBC_SOLVER_LIBRARY};${COIN_CGL_LIBRARY};${COIN_OSI_LIBRARY};${COIN_OSI_CLP_LIBRARY};${COIN_CLP_LIBRARIES}") - SET(COIN_LIBRARIES ${COIN_CBC_LIBRARIES}) + SET(COIN_INCLUDE_DIRS ${COIN_INCLUDE_DIR}) + SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARY};${COIN_COIN_UTILS_LIBRARY};${COIN_ZLIB_LIBRARY}") + IF(COIN_ZLIB_LIBRARY) + SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARIES};${COIN_ZLIB_LIBRARY}") + ENDIF(COIN_ZLIB_LIBRARY) + IF(COIN_BZ2_LIBRARY) + SET(COIN_CLP_LIBRARIES "${COIN_CLP_LIBRARIES};${COIN_BZ2_LIBRARY}") + ENDIF(COIN_BZ2_LIBRARY) + # Not required by cbc v2.5, but required by later versions in which case, + # the lower line should be commented out and this line used + #SET(COIN_CBC_LIBRARIES "${COIN_CBC_LIBRARY};${COIN_CBC_SOLVER_LIBRARY};${COIN_CGL_LIBRARY};${COIN_OSI_LIBRARY};${COIN_OSI_CBC_LIBRARY};${COIN_OSI_CLP_LIBRARY};${COIN_CLP_LIBRARIES}") + SET(COIN_CBC_LIBRARIES "${COIN_CBC_LIBRARY};${COIN_CBC_SOLVER_LIBRARY};${COIN_CGL_LIBRARY};${COIN_OSI_LIBRARY};${COIN_OSI_CLP_LIBRARY};${COIN_CLP_LIBRARIES}") + SET(COIN_LIBRARIES ${COIN_CBC_LIBRARIES}) ENDIF(COIN_FOUND) # # Report a synopsis of our findings # IF(COIN_INCLUDE_DIRS) - MESSAGE(STATUS "Found COIN Include Dirs: ${COIN_INCLUDE_DIRS}") + MESSAGE(STATUS "Found COIN Include Dirs: ${COIN_INCLUDE_DIRS}") ELSE(COIN_INCLUDE_DIRS) - MESSAGE(STATUS "COIN Include Dirs NOT FOUND") + MESSAGE(STATUS "COIN Include Dirs NOT FOUND") ENDIF(COIN_INCLUDE_DIRS) diff --git a/cmake/FindCyclus.cmake b/cmake/FindCyclus.cmake index b53a7e2..0a7e79a 100644 --- a/cmake/FindCyclus.cmake +++ b/cmake/FindCyclus.cmake @@ -7,24 +7,26 @@ # Check if we have an environment variable to cyclus root IF(DEFINED ENV{CYCLUS_ROOT_DIR}) - IF(NOT DEFINED CYCLUS_ROOT_DIR) - SET(CYCLUS_ROOT_DIR "$ENV{CYCLUS_ROOT_DIR}") - ELSE(NOT DEFINED CYCLUS_ROOT_DIR) - # Yell if both exist - MESSAGE(STATUS "\tTwo CYCLUS_ROOT_DIRs have been found:") - MESSAGE(STATUS "\t\tThe defined cmake variable CYCLUS_ROOT_DIR: ${CYCLUS_ROOT_DIR}") - MESSAGE(STATUS "\t\tThe environment variable CYCLUS_ROOT_DIR: $ENV{CYCLUS_ROOT_DIR}") - ENDIF(NOT DEFINED CYCLUS_ROOT_DIR) + IF(NOT DEFINED CYCLUS_ROOT_DIR) + SET(CYCLUS_ROOT_DIR "$ENV{CYCLUS_ROOT_DIR}") + ELSE(NOT DEFINED CYCLUS_ROOT_DIR) + # Yell if both exist + MESSAGE(STATUS "\tTwo CYCLUS_ROOT_DIRs have been found:") + MESSAGE(STATUS "\t\tThe defined cmake variable CYCLUS_ROOT_DIR: ${CYCLUS_ROOT_DIR}") + MESSAGE(STATUS "\t\tThe environment variable CYCLUS_ROOT_DIR: $ENV{CYCLUS_ROOT_DIR}") + ENDIF(NOT DEFINED CYCLUS_ROOT_DIR) ELSE(DEFINED ENV{CYCLUS_ROOT_DIR}) - FIND_PROGRAM(CYCLUS_BIN cyclus) - MESSAGE("cyclus bin dir: ${CYCLUS_BIN}") - IF(CYCLUS_BIN) - EXECUTE_PROCESS(COMMAND cyclus --install-path - OUTPUT_VARIABLE CYCLUS_ROOT_DIR - OUTPUT_STRIP_TRAILING_WHITESPACE) - ELSE(CYCLUS_BIN) - SET(CYCLUS_ROOT_DIR "$ENV{HOME}/.local") - ENDIF(CYCLUS_BIN) + IF(NOT DEFINED CYCLUS_ROOT_DIR) + FIND_PROGRAM(CYCLUS_BIN cyclus) + MESSAGE("cyclus bin dir: ${CYCLUS_BIN}") + IF(CYCLUS_BIN) + EXECUTE_PROCESS(COMMAND cyclus --install-path + OUTPUT_VARIABLE CYCLUS_ROOT_DIR + OUTPUT_STRIP_TRAILING_WHITESPACE) + ELSE(CYCLUS_BIN) + SET(CYCLUS_ROOT_DIR "$ENV{HOME}/.local") + ENDIF(CYCLUS_BIN) + ENDIF(NOT DEFINED CYCLUS_ROOT_DIR) ENDIF(DEFINED ENV{CYCLUS_ROOT_DIR}) # Let the user know if we're using a hint @@ -33,119 +35,119 @@ MESSAGE(STATUS "Using ${CYCLUS_ROOT_DIR} as CYCLUS_ROOT_DIR.") # Set the include dir, this will be the future basis for other # defined dirs FIND_PATH(CYCLUS_CORE_INCLUDE_DIR cyclus.h - HINTS "${CYCLUS_ROOT_DIR}" "${CYCLUS_ROOT_DIR}/cyclus" - "${CYCLUS_ROOT_DIR}/include" - "${CYCLUS_ROOT_DIR}/include/cyclus" - /usr/local/cyclus /opt/local/cyclus - PATH_SUFFIXES cyclus/include include include/cyclus) + HINTS "${CYCLUS_ROOT_DIR}" "${CYCLUS_ROOT_DIR}/cyclus" + "${CYCLUS_ROOT_DIR}/include" + "${CYCLUS_ROOT_DIR}/include/cyclus" + /usr/local/cyclus /opt/local/cyclus + PATH_SUFFIXES cyclus/include include include/cyclus) # Set the include dir, this will be the future basis for other # defined dirs FIND_PATH(CYCLUS_CORE_TEST_INCLUDE_DIR agent_tests.h - HINTS "${CYCLUS_ROOT_DIR}" "${CYCLUS_ROOT_DIR}/cyclus/tests" - "${CYCLUS_ROOT_DIR}/include" - "${CYCLUS_ROOT_DIR}/include/cyclus/tests" - /usr/local/cyclus /opt/local/cyclus - PATH_SUFFIXES cyclus/include include include/cyclus include/cyclus/tests cyclus/include/tests) + HINTS "${CYCLUS_ROOT_DIR}" "${CYCLUS_ROOT_DIR}/cyclus/tests" + "${CYCLUS_ROOT_DIR}/include" + "${CYCLUS_ROOT_DIR}/include/cyclus/tests" + /usr/local/cyclus /opt/local/cyclus + PATH_SUFFIXES cyclus/include include include/cyclus include/cyclus/tests cyclus/include/tests) # find the directory containing gtest FIND_PATH(CYCLUS_GTEST_INCLUDE_DIR gtest/gtest.h - HINTS "${CYCLUS_ROOT_DIR}" "${CYCLUS_ROOT_DIR}" - "${CYCLUS_ROOT_DIR}/include" - "${CYCLUS_ROOT_DIR}/include/cyclus" - /usr/local/cyclus /opt/local/cyclus - PATH_SUFFIXES cyclus/include include include/cyclus) + HINTS "${CYCLUS_ROOT_DIR}" "${CYCLUS_ROOT_DIR}" + "${CYCLUS_ROOT_DIR}/include" + "${CYCLUS_ROOT_DIR}/include/cyclus" + /usr/local/cyclus /opt/local/cyclus + PATH_SUFFIXES cyclus/include include include/cyclus) SET(CYCLUS_CORE_TEST_INCLUDE_DIR ${CYCLUS_CORE_TEST_INCLUDE_DIR} - ${CYCLUS_GTEST_INCLUDE_DIR}) + ${CYCLUS_GTEST_INCLUDE_DIR}) # Add the root dir to the hints SET(CYCLUS_ROOT_DIR "${CYCLUS_CORE_INCLUDE_DIR}/../..") # Look for the header files FIND_PATH(CYCLUS_CORE_SHARE_DIR cyclus.rng.in - HINTS "${CYCLUS_ROOT_DIR}" "${CYCLUS_ROOT_DIR}/cyclus" - "${CYCLUS_ROOT_DIR}/share" "${CYCLUS_ROOT_DIR}/share/cyclus" - /usr/local/cyclus /opt/local/cyclus - PATH_SUFFIXES cyclus/share share) + HINTS "${CYCLUS_ROOT_DIR}" "${CYCLUS_ROOT_DIR}/cyclus" + "${CYCLUS_ROOT_DIR}/share" "${CYCLUS_ROOT_DIR}/share/cyclus" + /usr/local/cyclus /opt/local/cyclus + PATH_SUFFIXES cyclus/share share) # Look for the library FIND_LIBRARY(CYCLUS_CORE_LIBRARY NAMES cyclus - HINTS "${CYCLUS_ROOT_DIR}" "${CYCLUS_ROOT_DIR}/cyclus" - /usr/local/cyclus/lib /usr/local/cyclus - /opt/local /opt/local/cyclus - PATH_SUFFIXES cyclus/lib lib) + HINTS "${CYCLUS_ROOT_DIR}" "${CYCLUS_ROOT_DIR}/cyclus" + /usr/local/cyclus/lib /usr/local/cyclus + /opt/local /opt/local/cyclus + PATH_SUFFIXES cyclus/lib lib) # Look for the library FIND_LIBRARY(CYCLUS_AGENT_TEST_LIBRARY NAMES baseagentunittests - HINTS "${CYCLUS_ROOT_DIR}" "${CYCLUS_ROOT_DIR}/cyclus" - /usr/local/cyclus/lib /usr/local/cyclus - /opt/local /opt/local/cyclus - PATH_SUFFIXES cyclus/lib lib lib/cyclus) + HINTS "${CYCLUS_ROOT_DIR}" "${CYCLUS_ROOT_DIR}/cyclus" + /usr/local/cyclus/lib /usr/local/cyclus + /opt/local /opt/local/cyclus + PATH_SUFFIXES cyclus/lib lib lib/cyclus) # Look for the library FIND_LIBRARY(CYCLUS_GTEST_LIBRARY NAMES gtest - HINTS "${CYCLUS_ROOT_DIR}" "${CYCLUS_ROOT_DIR}/cyclus" - "${CYCLUS_ROOT_DIR}/lib" "${CYCLUS_CORE_SHARE_DIR}/../lib" - /usr/local/cyclus/lib /usr/local/cyclus - /opt/local/lib /opt/local/cyclus/lib - PATH_SUFFIXES cyclus/lib lib) + HINTS "${CYCLUS_ROOT_DIR}" "${CYCLUS_ROOT_DIR}/cyclus" + "${CYCLUS_ROOT_DIR}/lib" "${CYCLUS_CORE_SHARE_DIR}/../lib" + /usr/local/cyclus/lib /usr/local/cyclus + /opt/local/lib /opt/local/cyclus/lib + PATH_SUFFIXES cyclus/lib lib) # Copy the results to the output variables. -IF (CYCLUS_CORE_INCLUDE_DIR AND CYCLUS_CORE_TEST_INCLUDE_DIR - AND CYCLUS_CORE_LIBRARY AND CYCLUS_GTEST_LIBRARY AND CYCLUS_CORE_SHARE_DIR - AND CYCLUS_AGENT_TEST_LIBRARY) - SET(CYCLUS_CORE_FOUND 1) - SET(CYCLUS_CORE_LIBRARIES ${CYCLUS_CORE_LIBRARY}) - SET(CYCLUS_TEST_LIBRARIES ${CYCLUS_GTEST_LIBRARY} ${CYCLUS_AGENT_TEST_LIBRARY}) - SET(CYCLUS_AGENT_TEST_LIBRARIES ${CYCLUS_AGENT_TEST_LIBRARY}) - SET(CYCLUS_CORE_INCLUDE_DIRS "${CYCLUS_CORE_INCLUDE_DIR}") - SET(CYCLUS_CORE_TEST_INCLUDE_DIRS "${CYCLUS_CORE_TEST_INCLUDE_DIR}") - SET(CYCLUS_CORE_SHARE_DIRS ${CYCLUS_CORE_SHARE_DIR}) - SET(CYCLUS_DEFAULT_TEST_DRIVER "${CYCLUS_CORE_SHARE_DIR}/cyclus_default_unit_test_driver.cc") -ELSE () - SET(CYCLUS_CORE_FOUND 0) - SET(CYCLUS_CORE_LIBRARIES) - SET(CYCLUS_TEST_LIBRARIES) - SET(CYCLUS_AGENT_TEST_LIBRARIES) - SET(CYCLUS_CORE_INCLUDE_DIRS) - SET(CYCLUS_CORE_TEST_INCLUDE_DIRS) - SET(CYCLUS_CORE_SHARE_DIRS) - SET(CYCLUS_DEFAULT_TEST_DRIVER) -ENDIF () +IF(CYCLUS_CORE_INCLUDE_DIR AND CYCLUS_CORE_TEST_INCLUDE_DIR + AND CYCLUS_CORE_LIBRARY AND CYCLUS_GTEST_LIBRARY AND CYCLUS_CORE_SHARE_DIR + AND CYCLUS_AGENT_TEST_LIBRARY) + SET(CYCLUS_CORE_FOUND 1) + SET(CYCLUS_CORE_LIBRARIES ${CYCLUS_CORE_LIBRARY}) + SET(CYCLUS_TEST_LIBRARIES ${CYCLUS_GTEST_LIBRARY} ${CYCLUS_AGENT_TEST_LIBRARY}) + SET(CYCLUS_AGENT_TEST_LIBRARIES ${CYCLUS_AGENT_TEST_LIBRARY}) + SET(CYCLUS_CORE_INCLUDE_DIRS "${CYCLUS_CORE_INCLUDE_DIR}") + SET(CYCLUS_CORE_TEST_INCLUDE_DIRS "${CYCLUS_CORE_TEST_INCLUDE_DIR}") + SET(CYCLUS_CORE_SHARE_DIRS ${CYCLUS_CORE_SHARE_DIR}) + SET(CYCLUS_DEFAULT_TEST_DRIVER "${CYCLUS_CORE_SHARE_DIR}/cyclus_default_unit_test_driver.cc") +ELSE() + SET(CYCLUS_CORE_FOUND 0) + SET(CYCLUS_CORE_LIBRARIES) + SET(CYCLUS_TEST_LIBRARIES) + SET(CYCLUS_AGENT_TEST_LIBRARIES) + SET(CYCLUS_CORE_INCLUDE_DIRS) + SET(CYCLUS_CORE_TEST_INCLUDE_DIRS) + SET(CYCLUS_CORE_SHARE_DIRS) + SET(CYCLUS_DEFAULT_TEST_DRIVER) +ENDIF() # Report the results. -IF (CYCLUS_CORE_FOUND) - SET(CYCLUS_CORE_DIR_MESSAGE "Found Cyclus Core Headers : " - ${CYCLUS_CORE_INCLUDE_DIRS} ) - SET(CYCLUS_CORE_TEST_DIR_MESSAGE "Found Cyclus Core Test Headers : " - ${CYCLUS_CORE_TEST_INCLUDE_DIRS} ) - SET(CYCLUS_CORE_SHARE_MESSAGE "Found Cyclus Core Shared Data : " - ${CYCLUS_CORE_SHARE_DIRS} ) - SET(CYCLUS_CORE_LIB_MESSAGE "Found Cyclus Core Library : " - ${CYCLUS_CORE_LIBRARIES} ) - SET(CYCLUS_TEST_LIB_MESSAGE "Found Cyclus Test Libraries : " - ${CYCLUS_TEST_LIBRARIES} ) - MESSAGE(STATUS ${CYCLUS_CORE_DIR_MESSAGE}) - MESSAGE(STATUS ${CYCLUS_CORE_TEST_DIR_MESSAGE}) - MESSAGE(STATUS ${CYCLUS_CORE_SHARE_MESSAGE}) - MESSAGE(STATUS ${CYCLUS_CORE_LIB_MESSAGE}) - MESSAGE(STATUS ${CYCLUS_TEST_LIB_MESSAGE}) -ELSE (CYCLUS_CORE_FOUND) - SET(CYCLUS_CORE_DIR_MESSAGE - "Cyclus was not found. Make sure CYCLUS_CORE_LIBRARY and CYCLUS_CORE_INCLUDE_DIR are set.") - IF (NOT Cyclus_FIND_QUIETLY) - MESSAGE(STATUS "${CYCLUS_CORE_DIR_MESSAGE}") - MESSAGE(STATUS "CYCLUS_CORE_SHARE_DIR was set to : ${CYCLUS_CORE_SHARE_DIR}") - MESSAGE(STATUS "CYCLUS_CORE_LIBRARY was set to : ${CYCLUS_CORE_LIBRARY}") - MESSAGE(STATUS "CYCLUS_TEST_LIBRARIES was set to : ${CYCLUS_GTEST_LIBRARIES}") - IF (Cyclus_FIND_REQUIRED) - MESSAGE(FATAL_ERROR "${cyclus_DIR_MESSAGE}") - ENDIF (Cyclus_FIND_REQUIRED) - ENDIF (NOT Cyclus_FIND_QUIETLY) -ENDIF (CYCLUS_CORE_FOUND) +IF(CYCLUS_CORE_FOUND) + SET(CYCLUS_CORE_DIR_MESSAGE "Found Cyclus Core Headers : " + ${CYCLUS_CORE_INCLUDE_DIRS}) + SET(CYCLUS_CORE_TEST_DIR_MESSAGE "Found Cyclus Core Test Headers : " + ${CYCLUS_CORE_TEST_INCLUDE_DIRS}) + SET(CYCLUS_CORE_SHARE_MESSAGE "Found Cyclus Core Shared Data : " + ${CYCLUS_CORE_SHARE_DIRS}) + SET(CYCLUS_CORE_LIB_MESSAGE "Found Cyclus Core Library : " + ${CYCLUS_CORE_LIBRARIES}) + SET(CYCLUS_TEST_LIB_MESSAGE "Found Cyclus Test Libraries : " + ${CYCLUS_TEST_LIBRARIES}) + MESSAGE(STATUS ${CYCLUS_CORE_DIR_MESSAGE}) + MESSAGE(STATUS ${CYCLUS_CORE_TEST_DIR_MESSAGE}) + MESSAGE(STATUS ${CYCLUS_CORE_SHARE_MESSAGE}) + MESSAGE(STATUS ${CYCLUS_CORE_LIB_MESSAGE}) + MESSAGE(STATUS ${CYCLUS_TEST_LIB_MESSAGE}) +ELSE(CYCLUS_CORE_FOUND) + SET(CYCLUS_CORE_DIR_MESSAGE + "Cyclus was not found. Make sure CYCLUS_CORE_LIBRARY and CYCLUS_CORE_INCLUDE_DIR are set.") + IF(NOT Cyclus_FIND_QUIETLY) + MESSAGE(STATUS "${CYCLUS_CORE_DIR_MESSAGE}") + MESSAGE(STATUS "CYCLUS_CORE_SHARE_DIR was set to : ${CYCLUS_CORE_SHARE_DIR}") + MESSAGE(STATUS "CYCLUS_CORE_LIBRARY was set to : ${CYCLUS_CORE_LIBRARY}") + MESSAGE(STATUS "CYCLUS_TEST_LIBRARIES was set to : ${CYCLUS_GTEST_LIBRARIES}") + IF(Cyclus_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "${cyclus_DIR_MESSAGE}") + ENDIF(Cyclus_FIND_REQUIRED) + ENDIF(NOT Cyclus_FIND_QUIETLY) +ENDIF(CYCLUS_CORE_FOUND) MARK_AS_ADVANCED( - CYCLUS_CORE_INCLUDE_DIR - CYCLUS_CORE_LIBRARY -) + CYCLUS_CORE_INCLUDE_DIR + CYCLUS_CORE_LIBRARY + ) diff --git a/cmake/FindGlib.cmake b/cmake/FindGlib.cmake index f1986c9..fc7b748 100644 --- a/cmake/FindGlib.cmake +++ b/cmake/FindGlib.cmake @@ -1,42 +1,42 @@ pkg_check_modules(GLIB_PKG glib-2.0) -if (GLIB_PKG_FOUND) +if(GLIB_PKG_FOUND) find_path(GLIB_INCLUDE_DIR NAMES glib.h PATH_SUFFIXES glib-2.0 - PATHS - ${GLIB_PKG_INCLUDE_DIRS} - /usr/include/glib-2.0 - /usr/include - /usr/local/include - ) + PATHS + ${GLIB_PKG_INCLUDE_DIRS} + /usr/include/glib-2.0 + /usr/include + /usr/local/include + ) find_path(GLIB_CONFIG_INCLUDE_DIR NAMES glibconfig.h PATHS ${GLIB_PKG_LIBDIR} PATH_SUFFIXES glib-2.0/include) find_library(GLIB_LIBRARIES NAMES glib-2.0 - PATHS - ${GLIB_PKG_LIBRARY_DIRS} - /usr/lib - /usr/local/lib - ) + PATHS + ${GLIB_PKG_LIBRARY_DIRS} + /usr/lib + /usr/local/lib + ) -else (GLIB_PKG_FOUND) +else(GLIB_PKG_FOUND) # Find Glib even if pkg-config is not working (eg. cross compiling to Windows) find_library(GLIB_LIBRARIES NAMES glib-2.0) - string (REGEX REPLACE "/[^/]*$" "" GLIB_LIBRARIES_DIR ${GLIB_LIBRARIES}) + string(REGEX REPLACE "/[^/]*$" "" GLIB_LIBRARIES_DIR ${GLIB_LIBRARIES}) find_path(GLIB_INCLUDE_DIR NAMES glib.h PATH_SUFFIXES glib-2.0) find_path(GLIB_CONFIG_INCLUDE_DIR NAMES glibconfig.h PATHS ${GLIB_LIBRARIES_DIR} PATH_SUFFIXES glib-2.0/include) -endif (GLIB_PKG_FOUND) +endif(GLIB_PKG_FOUND) -if (GLIB_INCLUDE_DIR AND GLIB_CONFIG_INCLUDE_DIR AND GLIB_LIBRARIES) +if(GLIB_INCLUDE_DIR AND GLIB_CONFIG_INCLUDE_DIR AND GLIB_LIBRARIES) set(GLIB_INCLUDE_DIRS ${GLIB_INCLUDE_DIR} ${GLIB_CONFIG_INCLUDE_DIR}) -endif (GLIB_INCLUDE_DIR AND GLIB_CONFIG_INCLUDE_DIR AND GLIB_LIBRARIES) +endif(GLIB_INCLUDE_DIR AND GLIB_CONFIG_INCLUDE_DIR AND GLIB_LIBRARIES) if(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES) - set(GLIB_FOUND TRUE CACHE INTERNAL "glib-2.0 found") - message(STATUS "Found glib-2.0: ${GLIB_INCLUDE_DIR}, ${GLIB_LIBRARIES}") + set(GLIB_FOUND TRUE CACHE INTERNAL "glib-2.0 found") + message(STATUS "Found glib-2.0: ${GLIB_INCLUDE_DIR}, ${GLIB_LIBRARIES}") else(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES) - set(GLIB_FOUND FALSE CACHE INTERNAL "glib-2.0 found") - message(STATUS "glib-2.0 not found.") + set(GLIB_FOUND FALSE CACHE INTERNAL "glib-2.0 found") + message(STATUS "glib-2.0 not found.") endif(GLIB_INCLUDE_DIRS AND GLIB_LIBRARIES) mark_as_advanced(GLIB_INCLUDE_DIR GLIB_CONFIG_INCLUDE_DIR GLIB_INCLUDE_DIRS GLIB_LIBRARIES) diff --git a/cmake/FindGlibmm.cmake b/cmake/FindGlibmm.cmake index 3a5968d..c028757 100644 --- a/cmake/FindGlibmm.cmake +++ b/cmake/FindGlibmm.cmake @@ -16,23 +16,23 @@ libfind_pkg_check_modules(Glibmm_PKGCONF glibmm-2.4) # Main include dir find_path(Glibmm_INCLUDE_DIR - NAMES glibmm/main.h - PATHS ${Glibmm_PKGCONF_INCLUDE_DIRS} - PATH_SUFFIXES glibmm-2.4 include/glibmm-2.4 -) + NAMES glibmm/main.h + PATHS ${Glibmm_PKGCONF_INCLUDE_DIRS} + PATH_SUFFIXES glibmm-2.4 include/glibmm-2.4 + ) # Glib-related libraries also use a separate config header, which is in lib dir find_path(GlibmmConfig_INCLUDE_DIR - NAMES glibmmconfig.h - PATHS ${Glibmm_PKGCONF_INCLUDE_DIRS} /usr - PATH_SUFFIXES lib/glibmm-2.4/include -) + NAMES glibmmconfig.h + PATHS ${Glibmm_PKGCONF_INCLUDE_DIRS} /usr + PATH_SUFFIXES lib/glibmm-2.4/include + ) # find lib find_path(Glibmm_PKGCONF_LIBRARY_DIRS - NAMES libglib-2.0.so - PATH_SUFFIXES lib -) + NAMES libglib-2.0.so + PATH_SUFFIXES lib + ) libfind_library(Glibmm glibmm 2.4) # Set the include dir variables and the libraries and let libfind_process do the rest. @@ -40,4 +40,3 @@ libfind_library(Glibmm glibmm 2.4) set(Glibmm_PROCESS_INCLUDES Glibmm_INCLUDE_DIR GlibmmConfig_INCLUDE_DIR GLIB_INCLUDE_DIRS SigC++_INCLUDE_DIRS) set(Glibmm_PROCESS_LIBS Glibmm_LIBRARY GLIB_LIBRARIES SigC++_LIBRARIES) libfind_process(Glibmm) - diff --git a/cmake/FindHDF5.cmake b/cmake/FindHDF5.cmake index 5b7cadd..1722a7e 100644 --- a/cmake/FindHDF5.cmake +++ b/cmake/FindHDF5.cmake @@ -26,7 +26,7 @@ # In addition to finding the includes and libraries required to compile an HDF5 # client application, this module also makes an effort to find tools that come # with the HDF5 distribution that may be useful for regression testing. -# +# # This module will define the following variables: # HDF5_INCLUDE_DIRS - Location of the hdf5 includes # HDF5_INCLUDE_DIR - Location of the hdf5 includes (deprecated) @@ -60,270 +60,268 @@ include(SelectLibraryConfigurations) include(FindPackageHandleStandardArgs) # List of the valid HDF5 components -set( HDF5_VALID_COMPONENTS +set(HDF5_VALID_COMPONENTS C CXX -) + ) # try to find the HDF5 wrapper compilers -find_program( HDF5_C_COMPILER_EXECUTABLE +find_program(HDF5_C_COMPILER_EXECUTABLE NAMES h5cc h5pcc HINTS ENV HDF5_ROOT PATH_SUFFIXES bin Bin - DOC "HDF5 Wrapper compiler. Used only to detect HDF5 compile flags." ) -mark_as_advanced( HDF5_C_COMPILER_EXECUTABLE ) + DOC "HDF5 Wrapper compiler. Used only to detect HDF5 compile flags.") +mark_as_advanced(HDF5_C_COMPILER_EXECUTABLE) -find_program( HDF5_CXX_COMPILER_EXECUTABLE +find_program(HDF5_CXX_COMPILER_EXECUTABLE NAMES h5c++ h5pc++ HINTS ENV HDF5_ROOT PATH_SUFFIXES bin Bin - DOC "HDF5 C++ Wrapper compiler. Used only to detect HDF5 compile flags." ) -mark_as_advanced( HDF5_CXX_COMPILER_EXECUTABLE ) + DOC "HDF5 C++ Wrapper compiler. Used only to detect HDF5 compile flags.") +mark_as_advanced(HDF5_CXX_COMPILER_EXECUTABLE) -find_program( HDF5_DIFF_EXECUTABLE +find_program(HDF5_DIFF_EXECUTABLE NAMES h5diff HINTS ENV HDF5_ROOT - PATH_SUFFIXES bin Bin - DOC "HDF5 file differencing tool." ) -mark_as_advanced( HDF5_DIFF_EXECUTABLE ) + PATH_SUFFIXES bin Bin + DOC "HDF5 file differencing tool.") +mark_as_advanced(HDF5_DIFF_EXECUTABLE) # Invoke the HDF5 wrapper compiler. The compiler return value is stored to the # return_value argument, the text output is stored to the output variable. -macro( _HDF5_invoke_compiler language output return_value ) - if( HDF5_${language}_COMPILER_EXECUTABLE ) - exec_program( ${HDF5_${language}_COMPILER_EXECUTABLE} +macro(_HDF5_invoke_compiler language output return_value) + if(HDF5_${language}_COMPILER_EXECUTABLE) + exec_program(${HDF5_${language}_COMPILER_EXECUTABLE} ARGS -show OUTPUT_VARIABLE ${output} RETURN_VALUE ${return_value} - ) - if( ${${return_value}} EQUAL 0 ) + ) + if(${${return_value}} EQUAL 0) # do nothing else() - message( STATUS - "Unable to determine HDF5 ${language} flags from HDF5 wrapper." ) + message(STATUS + "Unable to determine HDF5 ${language} flags from HDF5 wrapper.") endif() endif() endmacro() # Parse a compile line for definitions, includes, library paths, and libraries. -macro( _HDF5_parse_compile_line - compile_line_var - include_paths - definitions - library_paths - libraries ) +macro(_HDF5_parse_compile_line + compile_line_var + include_paths + definitions + library_paths + libraries) # Match the include paths - string( REGEX MATCHALL "-I([^\" ]+)" include_path_flags + string(REGEX MATCHALL "-I([^\" ]+)" include_path_flags "${${compile_line_var}}" - ) - foreach( IPATH ${include_path_flags} ) - string( REGEX REPLACE "^-I" "" IPATH ${IPATH} ) - string( REGEX REPLACE "//" "/" IPATH ${IPATH} ) - list( APPEND ${include_paths} ${IPATH} ) + ) + foreach(IPATH ${include_path_flags}) + string(REGEX REPLACE "^-I" "" IPATH ${IPATH}) + string(REGEX REPLACE "//" "/" IPATH ${IPATH}) + list(APPEND ${include_paths} ${IPATH}) endforeach() # Match the definitions - string( REGEX MATCHALL "-D[^ ]*" definition_flags "${${compile_line_var}}" ) - foreach( DEF ${definition_flags} ) - list( APPEND ${definitions} ${DEF} ) + string(REGEX MATCHALL "-D[^ ]*" definition_flags "${${compile_line_var}}") + foreach(DEF ${definition_flags}) + list(APPEND ${definitions} ${DEF}) endforeach() # Match the library paths - string( REGEX MATCHALL "-L([^\" ]+|\"[^\"]+\")" library_path_flags + string(REGEX MATCHALL "-L([^\" ]+|\"[^\"]+\")" library_path_flags "${${compile_line_var}}" - ) - - foreach( LPATH ${library_path_flags} ) - string( REGEX REPLACE "^-L" "" LPATH ${LPATH} ) - string( REGEX REPLACE "//" "/" LPATH ${LPATH} ) - list( APPEND ${library_paths} ${LPATH} ) + ) + + foreach(LPATH ${library_path_flags}) + string(REGEX REPLACE "^-L" "" LPATH ${LPATH}) + string(REGEX REPLACE "//" "/" LPATH ${LPATH}) + list(APPEND ${library_paths} ${LPATH}) endforeach() # now search for the library names specified in the compile line (match -l...) # match only -l's preceded by a space or comma # this is to exclude directory names like xxx-linux/ - string( REGEX MATCHALL "[, ]-l([^\", ]+)" library_name_flags - "${${compile_line_var}}" ) + string(REGEX MATCHALL "[, ]-l([^\", ]+)" library_name_flags + "${${compile_line_var}}") # strip the -l from all of the library flags and add to the search list - foreach( LIB ${library_name_flags} ) - string( REGEX REPLACE "^[, ]-l" "" LIB ${LIB} ) - list( APPEND ${libraries} ${LIB} ) + foreach(LIB ${library_name_flags}) + string(REGEX REPLACE "^[, ]-l" "" LIB ${LIB}) + list(APPEND ${libraries} ${LIB}) endforeach() endmacro() -if( HDF5_INCLUDE_DIRS AND HDF5_LIBRARIES ) +if(HDF5_INCLUDE_DIRS AND HDF5_LIBRARIES) # Do nothing: we already have HDF5_INCLUDE_PATH and HDF5_LIBRARIES in the # cache, it would be a shame to override them else() - _HDF5_invoke_compiler( C HDF5_C_COMPILE_LINE HDF5_C_RETURN_VALUE ) - _HDF5_invoke_compiler( CXX HDF5_CXX_COMPILE_LINE HDF5_CXX_RETURN_VALUE ) + _HDF5_invoke_compiler(C HDF5_C_COMPILE_LINE HDF5_C_RETURN_VALUE) + _HDF5_invoke_compiler(CXX HDF5_CXX_COMPILE_LINE HDF5_CXX_RETURN_VALUE) - if( NOT HDF5_FIND_COMPONENTS ) - set( HDF5_LANGUAGE_BINDINGS "C" ) + if(NOT HDF5_FIND_COMPONENTS) + set(HDF5_LANGUAGE_BINDINGS "C") else() # add the extra specified components, ensuring that they are valid. - foreach( component ${HDF5_FIND_COMPONENTS} ) - list( FIND HDF5_VALID_COMPONENTS ${component} component_location ) - if( ${component_location} EQUAL -1 ) - message( FATAL_ERROR - "\"${component}\" is not a valid HDF5 component." ) + foreach(component ${HDF5_FIND_COMPONENTS}) + list(FIND HDF5_VALID_COMPONENTS ${component} component_location) + if(${component_location} EQUAL -1) + message(FATAL_ERROR + "\"${component}\" is not a valid HDF5 component.") else() - list( APPEND HDF5_LANGUAGE_BINDINGS ${component} ) + list(APPEND HDF5_LANGUAGE_BINDINGS ${component}) endif() endforeach() endif() - + # seed the initial lists of libraries to find with items we know we need - set( HDF5_C_LIBRARY_NAMES_INIT hdf5_hl hdf5 ) - set( HDF5_CXX_LIBRARY_NAMES_INIT hdf5_cpp ${HDF5_C_LIBRARY_NAMES_INIT} ) - - foreach( LANGUAGE ${HDF5_LANGUAGE_BINDINGS} ) - if( HDF5_${LANGUAGE}_COMPILE_LINE ) - _HDF5_parse_compile_line( HDF5_${LANGUAGE}_COMPILE_LINE - HDF5_${LANGUAGE}_INCLUDE_FLAGS - HDF5_${LANGUAGE}_DEFINITIONS - HDF5_${LANGUAGE}_LIBRARY_DIRS - HDF5_${LANGUAGE}_LIBRARY_NAMES + set(HDF5_C_LIBRARY_NAMES_INIT hdf5_hl hdf5) + set(HDF5_CXX_LIBRARY_NAMES_INIT hdf5_cpp ${HDF5_C_LIBRARY_NAMES_INIT}) + + foreach(LANGUAGE ${HDF5_LANGUAGE_BINDINGS}) + if(HDF5_${LANGUAGE}_COMPILE_LINE) + _HDF5_parse_compile_line(HDF5_${LANGUAGE}_COMPILE_LINE + HDF5_${LANGUAGE}_INCLUDE_FLAGS + HDF5_${LANGUAGE}_DEFINITIONS + HDF5_${LANGUAGE}_LIBRARY_DIRS + HDF5_${LANGUAGE}_LIBRARY_NAMES ) - - # take a guess that the includes may be in the 'include' sibling directory - # of a library directory. - foreach( dir ${HDF5_${LANGUAGE}_LIBRARY_DIRS} ) - list( APPEND HDF5_${LANGUAGE}_INCLUDE_FLAGS ${dir}/../include ) - endforeach() - endif() - # set the definitions for the language bindings. - list( APPEND HDF5_DEFINITIONS ${HDF5_${LANGUAGE}_DEFINITIONS} ) - - # find the HDF5 include directories - find_path( HDF5_${LANGUAGE}_INCLUDE_DIR hdf5.h - HINTS - ${HDF5_${LANGUAGE}_INCLUDE_FLAGS} - ENV - HDF5_ROOT - PATHS - $ENV{HOME}/.local/include - PATH_SUFFIXES - include - Include - ) - mark_as_advanced( HDF5_${LANGUAGE}_INCLUDE_DIR ) - list( APPEND HDF5_INCLUDE_DIRS ${HDF5_${LANGUAGE}_INCLUDE_DIR} ) - - set( HDF5_${LANGUAGE}_LIBRARY_NAMES - ${HDF5_${LANGUAGE}_LIBRARY_NAMES_INIT} - ${HDF5_${LANGUAGE}_LIBRARY_NAMES} ) - - # find the HDF5 libraries - foreach( LIB ${HDF5_${LANGUAGE}_LIBRARY_NAMES} ) - if( UNIX AND HDF5_USE_STATIC_LIBRARIES ) - # According to bug 1643 on the CMake bug tracker, this is the - # preferred method for searching for a static library. - # See http://www.cmake.org/Bug/view.php?id=1643. We search - # first for the full static library name, but fall back to a - # generic search on the name if the static search fails. - set( THIS_LIBRARY_SEARCH_DEBUG lib${LIB}d.a ${LIB}d ) - set( THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a ${LIB} ) - else() - set( THIS_LIBRARY_SEARCH_DEBUG ${LIB}d ) - set( THIS_LIBRARY_SEARCH_RELEASE ${LIB} ) - endif() - find_library( HDF5_${LIB}_LIBRARY_DEBUG - NAMES ${THIS_LIBRARY_SEARCH_DEBUG} - HINTS ${HDF5_${LANGUAGE}_LIBRARY_DIRS} - ENV HDF5_ROOT - PATH_SUFFIXES lib Lib ) - find_library( HDF5_${LIB}_LIBRARY_RELEASE - NAMES ${THIS_LIBRARY_SEARCH_RELEASE} - HINTS ${HDF5_${LANGUAGE}_LIBRARY_DIRS} - ENV HDF5_ROOT - PATH_SUFFIXES lib Lib ) - select_library_configurations( HDF5_${LIB} ) - # even though we adjusted the individual library names in - # select_library_configurations, we still need to distinguish - # between debug and release variants because HDF5_LIBRARIES will - # need to specify different lists for debug and optimized builds. - # We can't just use the HDF5_${LIB}_LIBRARY variable (which was set - # up by the selection macro above) because it may specify debug and - # optimized variants for a particular library, but a list of - # libraries is allowed to specify debug and optimized only once. - list( APPEND HDF5_${LANGUAGE}_LIBRARIES_DEBUG - ${HDF5_${LIB}_LIBRARY_DEBUG} ) - list( APPEND HDF5_${LANGUAGE}_LIBRARIES_RELEASE - ${HDF5_${LIB}_LIBRARY_RELEASE} ) + # take a guess that the includes may be in the 'include' sibling directory + # of a library directory. + foreach(dir ${HDF5_${LANGUAGE}_LIBRARY_DIRS}) + list(APPEND HDF5_${LANGUAGE}_INCLUDE_FLAGS ${dir}/../include) endforeach() - list( APPEND HDF5_LIBRARY_DIRS ${HDF5_${LANGUAGE}_LIBRARY_DIRS} ) - - # Append the libraries for this language binding to the list of all - # required libraries. - list( APPEND HDF5_LIBRARIES_DEBUG - ${HDF5_${LANGUAGE}_LIBRARIES_DEBUG} ) - list( APPEND HDF5_LIBRARIES_RELEASE - ${HDF5_${LANGUAGE}_LIBRARIES_RELEASE} ) - endforeach() - - # We may have picked up some duplicates in various lists during the above - # process for the language bindings (both the C and C++ bindings depend on - # libz for example). Remove the duplicates. - if( HDF5_INCLUDE_DIRS ) - list( REMOVE_DUPLICATES HDF5_INCLUDE_DIRS ) - endif() - if( HDF5_LIBRARIES_DEBUG ) - list( REMOVE_DUPLICATES HDF5_LIBRARIES_DEBUG ) - endif() - if( HDF5_LIBRARIES_RELEASE ) - list( REMOVE_DUPLICATES HDF5_LIBRARIES_RELEASE ) - endif() - if( HDF5_LIBRARY_DIRS ) - list( REMOVE_DUPLICATES HDF5_LIBRARY_DIRS ) endif() - # Construct the complete list of HDF5 libraries with debug and optimized - # variants when the generator supports them. - if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) - set( HDF5_LIBRARIES - debug ${HDF5_LIBRARIES_DEBUG} - optimized ${HDF5_LIBRARIES_RELEASE} ) - else() - set( HDF5_LIBRARIES ${HDF5_LIBRARIES_RELEASE} ) - endif() + # set the definitions for the language bindings. + list(APPEND HDF5_DEFINITIONS ${HDF5_${LANGUAGE}_DEFINITIONS}) - # If the HDF5 include directory was found, open H5pubconf.h to determine if - # HDF5 was compiled with parallel IO support - set( HDF5_IS_PARALLEL FALSE ) - foreach( _dir HDF5_INCLUDE_DIRS ) - if( EXISTS "${_dir}/H5pubconf.h" ) - file( STRINGS "${_dir}/H5pubconf.h" - HDF5_HAVE_PARALLEL_DEFINE - REGEX "HAVE_PARALLEL 1" ) - if( HDF5_HAVE_PARALLEL_DEFINE ) - set( HDF5_IS_PARALLEL TRUE ) - endif() + # find the HDF5 include directories + find_path(HDF5_${LANGUAGE}_INCLUDE_DIR hdf5.h + HINTS + ${HDF5_${LANGUAGE}_INCLUDE_FLAGS} + ENV + HDF5_ROOT + PATHS + $ENV{HOME}/.local/include + PATH_SUFFIXES + include + Include + ) + mark_as_advanced(HDF5_${LANGUAGE}_INCLUDE_DIR) + list(APPEND HDF5_INCLUDE_DIRS ${HDF5_${LANGUAGE}_INCLUDE_DIR}) + + set(HDF5_${LANGUAGE}_LIBRARY_NAMES + ${HDF5_${LANGUAGE}_LIBRARY_NAMES_INIT} + ${HDF5_${LANGUAGE}_LIBRARY_NAMES}) + + # find the HDF5 libraries + foreach(LIB ${HDF5_${LANGUAGE}_LIBRARY_NAMES}) + if(UNIX AND HDF5_USE_STATIC_LIBRARIES) + # According to bug 1643 on the CMake bug tracker, this is the + # preferred method for searching for a static library. + # See http://www.cmake.org/Bug/view.php?id=1643. We search + # first for the full static library name, but fall back to a + # generic search on the name if the static search fails. + set(THIS_LIBRARY_SEARCH_DEBUG lib${LIB}d.a ${LIB}d) + set(THIS_LIBRARY_SEARCH_RELEASE lib${LIB}.a ${LIB}) + else() + set(THIS_LIBRARY_SEARCH_DEBUG ${LIB}d) + set(THIS_LIBRARY_SEARCH_RELEASE ${LIB}) endif() + find_library(HDF5_${LIB}_LIBRARY_DEBUG + NAMES ${THIS_LIBRARY_SEARCH_DEBUG} + HINTS ${HDF5_${LANGUAGE}_LIBRARY_DIRS} + ENV HDF5_ROOT + PATH_SUFFIXES lib Lib) + find_library(HDF5_${LIB}_LIBRARY_RELEASE + NAMES ${THIS_LIBRARY_SEARCH_RELEASE} + HINTS ${HDF5_${LANGUAGE}_LIBRARY_DIRS} + ENV HDF5_ROOT + PATH_SUFFIXES lib Lib) + select_library_configurations(HDF5_${LIB}) + # even though we adjusted the individual library names in + # select_library_configurations, we still need to distinguish + # between debug and release variants because HDF5_LIBRARIES will + # need to specify different lists for debug and optimized builds. + # We can't just use the HDF5_${LIB}_LIBRARY variable (which was set + # up by the selection macro above) because it may specify debug and + # optimized variants for a particular library, but a list of + # libraries is allowed to specify debug and optimized only once. + list(APPEND HDF5_${LANGUAGE}_LIBRARIES_DEBUG + ${HDF5_${LIB}_LIBRARY_DEBUG}) + list(APPEND HDF5_${LANGUAGE}_LIBRARIES_RELEASE + ${HDF5_${LIB}_LIBRARY_RELEASE}) endforeach() - set( HDF5_IS_PARALLEL ${HDF5_IS_PARALLEL} CACHE BOOL - "HDF5 library compiled with parallel IO support" ) - mark_as_advanced( HDF5_IS_PARALLEL ) + list(APPEND HDF5_LIBRARY_DIRS ${HDF5_${LANGUAGE}_LIBRARY_DIRS}) + + # Append the libraries for this language binding to the list of all + # required libraries. + list(APPEND HDF5_LIBRARIES_DEBUG + ${HDF5_${LANGUAGE}_LIBRARIES_DEBUG}) + list(APPEND HDF5_LIBRARIES_RELEASE + ${HDF5_${LANGUAGE}_LIBRARIES_RELEASE}) +endforeach() + +# We may have picked up some duplicates in various lists during the above +# process for the language bindings (both the C and C++ bindings depend on +# libz for example). Remove the duplicates. +if(HDF5_INCLUDE_DIRS) + list(REMOVE_DUPLICATES HDF5_INCLUDE_DIRS) +endif() +if(HDF5_LIBRARIES_DEBUG) + list(REMOVE_DUPLICATES HDF5_LIBRARIES_DEBUG) +endif() +if(HDF5_LIBRARIES_RELEASE) + list(REMOVE_DUPLICATES HDF5_LIBRARIES_RELEASE) +endif() +if(HDF5_LIBRARY_DIRS) + list(REMOVE_DUPLICATES HDF5_LIBRARY_DIRS) +endif() +# Construct the complete list of HDF5 libraries with debug and optimized +# variants when the generator supports them. +if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + set(HDF5_LIBRARIES + debug ${HDF5_LIBRARIES_DEBUG} + optimized ${HDF5_LIBRARIES_RELEASE}) +else() + set(HDF5_LIBRARIES ${HDF5_LIBRARIES_RELEASE}) endif() -find_package_handle_standard_args( HDF5 DEFAULT_MSG - HDF5_LIBRARIES +# If the HDF5 include directory was found, open H5pubconf.h to determine if +# HDF5 was compiled with parallel IO support +set(HDF5_IS_PARALLEL FALSE) +foreach(_dir HDF5_INCLUDE_DIRS) + if(EXISTS "${_dir}/H5pubconf.h") + file(STRINGS "${_dir}/H5pubconf.h" + HDF5_HAVE_PARALLEL_DEFINE + REGEX "HAVE_PARALLEL 1") + if(HDF5_HAVE_PARALLEL_DEFINE) + set(HDF5_IS_PARALLEL TRUE) + endif() + endif() +endforeach() +set(HDF5_IS_PARALLEL ${HDF5_IS_PARALLEL} CACHE BOOL + "HDF5 library compiled with parallel IO support") +mark_as_advanced(HDF5_IS_PARALLEL) + +endif() + +find_package_handle_standard_args(HDF5 DEFAULT_MSG + HDF5_LIBRARIES HDF5_INCLUDE_DIRS -) + ) -mark_as_advanced( - HDF5_INCLUDE_DIRS - HDF5_LIBRARIES +mark_as_advanced( + HDF5_INCLUDE_DIRS + HDF5_LIBRARIES HDF5_DEFINTIONS HDF5_LIBRARY_DIRS HDF5_C_COMPILER_EXECUTABLE - HDF5_CXX_COMPILER_EXECUTABLE ) + HDF5_CXX_COMPILER_EXECUTABLE) # For backwards compatibility we set HDF5_INCLUDE_DIR to the value of # HDF5_INCLUDE_DIRS -set( HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}" ) - - +set(HDF5_INCLUDE_DIR "${HDF5_INCLUDE_DIRS}") diff --git a/cmake/FindLibXML++.cmake b/cmake/FindLibXML++.cmake index 4727bf8..55021e7 100644 --- a/cmake/FindLibXML++.cmake +++ b/cmake/FindLibXML++.cmake @@ -16,23 +16,23 @@ libfind_pkg_check_modules(LibXML++_PKGCONF libxml++-2.6) # Main include dir find_path(LibXML++_INCLUDE_DIR - NAMES libxml++/libxml++.h - PATHS ${LibXML++_PKGCONF_INCLUDE_DIRS} - PATH_SUFFIXES libxml++-2.6 include/libxml++-2.6 -) + NAMES libxml++/libxml++.h + PATHS ${LibXML++_PKGCONF_INCLUDE_DIRS} + PATH_SUFFIXES libxml++-2.6 include/libxml++-2.6 + ) # Glib-related libraries also use a separate config header, which is in lib dir find_path(LibXML++Config_INCLUDE_DIR - NAMES libxml++config.h - PATHS ${LibXML++_PKGCONF_INCLUDE_DIRS} /usr - PATH_SUFFIXES lib/libxml++-2.6/include -) + NAMES libxml++config.h + PATHS ${LibXML++_PKGCONF_INCLUDE_DIRS} /usr + PATH_SUFFIXES lib/libxml++-2.6/include + ) # find lib find_path(LibXML++_PKGCONF_LIBRARY_DIRS - NAMES xml++-2.6 - PATH_SUFFIXES lib -) + NAMES xml++-2.6 + PATH_SUFFIXES lib + ) libfind_library(LibXML++ xml++ 2.6) # # Finally the library itself # find_library(LibXML++_LIBRARY @@ -45,4 +45,4 @@ libfind_library(LibXML++ xml++ 2.6) set(LibXML++_PROCESS_INCLUDES LibXML++_INCLUDE_DIR LibXML++Config_INCLUDE_DIR LIBXML2_INCLUDE_DIR Glibmm_INCLUDE_DIRS) set(LibXML++_PROCESS_LIBS LibXML++_LIBRARY LIBXML2_LIBRARIES Glibmm_LIBRARIES) -libfind_process(LibXML++) \ No newline at end of file +libfind_process(LibXML++) diff --git a/cmake/FindSigC++.cmake b/cmake/FindSigC++.cmake index 6601bf6..906d05b 100644 --- a/cmake/FindSigC++.cmake +++ b/cmake/FindSigC++.cmake @@ -12,23 +12,23 @@ libfind_pkg_check_modules(SigC++_PKGCONF sigc++-2.0) # Main include dir find_path(SigC++_INCLUDE_DIR - NAMES sigc++/sigc++.h - PATHS ${SigC++_PKGCONF_INCLUDE_DIRS} ${SigC++_PKGCONF_INCLUDE_DIRS}/include - PATH_SUFFIXES include/sigc++-2.0 sigc++-2.0 -) + NAMES sigc++/sigc++.h + PATHS ${SigC++_PKGCONF_INCLUDE_DIRS} ${SigC++_PKGCONF_INCLUDE_DIRS}/include + PATH_SUFFIXES include/sigc++-2.0 sigc++-2.0 + ) # Glib-related libraries also use a separate config header, which is in lib dir find_path(SigC++Config_INCLUDE_DIR - NAMES sigc++config.h - PATHS ${SigC++_PKGCONF_INCLUDE_DIRS} /usr - PATH_SUFFIXES lib/sigc++-2.0/include -) + NAMES sigc++config.h + PATHS ${SigC++_PKGCONF_INCLUDE_DIRS} /usr + PATH_SUFFIXES lib/sigc++-2.0/include + ) # find lib find_path(SigC++_PKGCONF_LIBRARY_DIRS - NAMES libsigc-2.0.so - PATH_SUFFIXES lib -) + NAMES libsigc-2.0.so + PATH_SUFFIXES lib + ) libfind_library(SigC++ sigc 2.0) # Set the include dir variables and the libraries and let libfind_process do the rest. @@ -36,4 +36,3 @@ libfind_library(SigC++ sigc 2.0) set(SigC++_PROCESS_INCLUDES SigC++_INCLUDE_DIR SigC++Config_INCLUDE_DIR) set(SigC++_PROCESS_LIBS SigC++_LIBRARY) libfind_process(SigC++) - diff --git a/cmake/FindSqlite3.cmake b/cmake/FindSqlite3.cmake index 0eccec2..c7d3778 100644 --- a/cmake/FindSqlite3.cmake +++ b/cmake/FindSqlite3.cmake @@ -12,45 +12,45 @@ # # Generated by CModuler, a CMake Module Generator - http://gitorious.org/cmoduler -IF( SQLITE3_INCLUDE_DIR AND SQLITE3_LIBRARY_RELEASE AND SQLITE3_LIBRARY_DEBUG ) +IF(SQLITE3_INCLUDE_DIR AND SQLITE3_LIBRARY_RELEASE AND SQLITE3_LIBRARY_DEBUG) SET(SQLITE3_FIND_QUIETLY TRUE) -ENDIF( SQLITE3_INCLUDE_DIR AND SQLITE3_LIBRARY_RELEASE AND SQLITE3_LIBRARY_DEBUG ) - -FIND_PATH( SQLITE3_INCLUDE_DIR sqlite3.h ) - -FIND_LIBRARY(SQLITE3_LIBRARY_RELEASE NAMES sqlite3 ) - -FIND_LIBRARY(SQLITE3_LIBRARY_DEBUG NAMES sqlite3 sqlite3d HINTS /usr/lib/debug/usr/lib/ ) - -IF( SQLITE3_LIBRARY_RELEASE OR SQLITE3_LIBRARY_DEBUG AND SQLITE3_INCLUDE_DIR ) - SET( SQLITE3_FOUND TRUE ) -ENDIF( SQLITE3_LIBRARY_RELEASE OR SQLITE3_LIBRARY_DEBUG AND SQLITE3_INCLUDE_DIR ) - -IF( SQLITE3_LIBRARY_DEBUG AND SQLITE3_LIBRARY_RELEASE ) - # if the generator supports configuration types then set - # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value - IF( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) - SET( SQLITE3_LIBRARIES optimized ${SQLITE3_LIBRARY_RELEASE} debug ${SQLITE3_LIBRARY_DEBUG} ) - ELSE( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) - # if there are no configuration types and CMAKE_BUILD_TYPE has no value - # then just use the release libraries - SET( SQLITE3_LIBRARIES ${SQLITE3_LIBRARY_RELEASE} ) - ENDIF( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) -ELSEIF( SQLITE3_LIBRARY_RELEASE ) - SET( SQLITE3_LIBRARIES ${SQLITE3_LIBRARY_RELEASE} ) -ELSE( SQLITE3_LIBRARY_DEBUG AND SQLITE3_LIBRARY_RELEASE ) - SET( SQLITE3_LIBRARIES ${SQLITE3_LIBRARY_DEBUG} ) -ENDIF( SQLITE3_LIBRARY_DEBUG AND SQLITE3_LIBRARY_RELEASE ) - -IF( SQLITE3_FOUND ) - IF( NOT SQLITE3_FIND_QUIETLY ) - MESSAGE( STATUS "Found Sqlite3 header file in ${SQLITE3_INCLUDE_DIR}") - MESSAGE( STATUS "Found Sqlite3 libraries: ${SQLITE3_LIBRARIES}") - ENDIF( NOT SQLITE3_FIND_QUIETLY ) +ENDIF(SQLITE3_INCLUDE_DIR AND SQLITE3_LIBRARY_RELEASE AND SQLITE3_LIBRARY_DEBUG) + +FIND_PATH(SQLITE3_INCLUDE_DIR sqlite3.h) + +FIND_LIBRARY(SQLITE3_LIBRARY_RELEASE NAMES sqlite3) + +FIND_LIBRARY(SQLITE3_LIBRARY_DEBUG NAMES sqlite3 sqlite3d HINTS /usr/lib/debug/usr/lib/) + +IF(SQLITE3_LIBRARY_RELEASE OR SQLITE3_LIBRARY_DEBUG AND SQLITE3_INCLUDE_DIR) + SET(SQLITE3_FOUND TRUE) +ENDIF(SQLITE3_LIBRARY_RELEASE OR SQLITE3_LIBRARY_DEBUG AND SQLITE3_INCLUDE_DIR) + +IF(SQLITE3_LIBRARY_DEBUG AND SQLITE3_LIBRARY_RELEASE) + # if the generator supports configuration types then set + # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value + IF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + SET(SQLITE3_LIBRARIES optimized ${SQLITE3_LIBRARY_RELEASE} debug ${SQLITE3_LIBRARY_DEBUG}) + ELSE(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + # if there are no configuration types and CMAKE_BUILD_TYPE has no value + # then just use the release libraries + SET(SQLITE3_LIBRARIES ${SQLITE3_LIBRARY_RELEASE}) + ENDIF(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) +ELSEIF(SQLITE3_LIBRARY_RELEASE) + SET(SQLITE3_LIBRARIES ${SQLITE3_LIBRARY_RELEASE}) +ELSE(SQLITE3_LIBRARY_DEBUG AND SQLITE3_LIBRARY_RELEASE) + SET(SQLITE3_LIBRARIES ${SQLITE3_LIBRARY_DEBUG}) +ENDIF(SQLITE3_LIBRARY_DEBUG AND SQLITE3_LIBRARY_RELEASE) + +IF(SQLITE3_FOUND) + IF(NOT SQLITE3_FIND_QUIETLY) + MESSAGE(STATUS "Found Sqlite3 header file in ${SQLITE3_INCLUDE_DIR}") + MESSAGE(STATUS "Found Sqlite3 libraries: ${SQLITE3_LIBRARIES}") + ENDIF(NOT SQLITE3_FIND_QUIETLY) ELSE(SQLITE3_FOUND) - IF( SQLITE3_FIND_REQUIRED) - MESSAGE( FATAL_ERROR "Could not find Sqlite3" ) - ELSE( SQLITE3_FIND_REQUIRED) - MESSAGE( STATUS "Optional package Sqlite3 was not found" ) - ENDIF( SQLITE3_FIND_REQUIRED) + IF(SQLITE3_FIND_REQUIRED) + MESSAGE(FATAL_ERROR "Could not find Sqlite3") + ELSE(SQLITE3_FIND_REQUIRED) + MESSAGE(STATUS "Optional package Sqlite3 was not found") + ENDIF(SQLITE3_FIND_REQUIRED) ENDIF(SQLITE3_FOUND) diff --git a/cmake/LibFindMacros.cmake b/cmake/LibFindMacros.cmake index 69975c5..1c75d10 100644 --- a/cmake/LibFindMacros.cmake +++ b/cmake/LibFindMacros.cmake @@ -2,32 +2,32 @@ # used for the current package. For this to work, the first parameter must be the # prefix of the current package, then the prefix of the new package etc, which are # passed to find_package. -macro (libfind_package PREFIX) - set (LIBFIND_PACKAGE_ARGS ${ARGN}) - if (${PREFIX}_FIND_QUIETLY) - set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET) - endif (${PREFIX}_FIND_QUIETLY) - if (${PREFIX}_FIND_REQUIRED) - set (LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED) - endif (${PREFIX}_FIND_REQUIRED) - find_package(${LIBFIND_PACKAGE_ARGS}) -endmacro (libfind_package) +macro(libfind_package PREFIX) + set(LIBFIND_PACKAGE_ARGS ${ARGN}) + if(${PREFIX}_FIND_QUIETLY) + set(LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} QUIET) + endif(${PREFIX}_FIND_QUIETLY) + if(${PREFIX}_FIND_REQUIRED) + set(LIBFIND_PACKAGE_ARGS ${LIBFIND_PACKAGE_ARGS} REQUIRED) + endif(${PREFIX}_FIND_REQUIRED) + find_package(${LIBFIND_PACKAGE_ARGS}) +endmacro(libfind_package) # CMake developers made the UsePkgConfig system deprecated in the same release (2.6) # where they added pkg_check_modules. Consequently I need to support both in my scripts # to avoid those deprecated warnings. Here's a helper that does just that. # Works identically to pkg_check_modules, except that no checks are needed prior to use. -macro (libfind_pkg_check_modules PREFIX PKGNAME) - if (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) - include(UsePkgConfig) - pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS) - else (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) - find_package(PkgConfig) - if (PKG_CONFIG_FOUND) - pkg_check_modules(${PREFIX} ${PKGNAME}) - endif (PKG_CONFIG_FOUND) - endif (${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) -endmacro (libfind_pkg_check_modules) +macro(libfind_pkg_check_modules PREFIX PKGNAME) + if(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + include(UsePkgConfig) + pkgconfig(${PKGNAME} ${PREFIX}_INCLUDE_DIRS ${PREFIX}_LIBRARY_DIRS ${PREFIX}_LDFLAGS ${PREFIX}_CFLAGS) + else(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) + find_package(PkgConfig) + if(PKG_CONFIG_FOUND) + pkg_check_modules(${PREFIX} ${PKGNAME}) + endif(PKG_CONFIG_FOUND) + endif(${CMAKE_MAJOR_VERSION} EQUAL 2 AND ${CMAKE_MINOR_VERSION} EQUAL 4) +endmacro(libfind_pkg_check_modules) # Do the final processing once the paths have been detected. # If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain @@ -35,65 +35,64 @@ endmacro (libfind_pkg_check_modules) # Ditto for ${PREFIX}_PROCESS_LIBS and library files. # Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES. # Also handles errors in case library detection was required, etc. -macro (libfind_process PREFIX) - # Skip processing if already processed during this run - if (NOT ${PREFIX}_FOUND) - # Start with the assumption that the library was found - set (${PREFIX}_FOUND TRUE) +macro(libfind_process PREFIX) + # Skip processing if already processed during this run + if(NOT ${PREFIX}_FOUND) + # Start with the assumption that the library was found + set(${PREFIX}_FOUND TRUE) - # Process all includes and set _FOUND to false if any are missing - foreach (i ${${PREFIX}_PROCESS_INCLUDES}) - if (${i}) - set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}}) - mark_as_advanced(${i}) - else (${i}) - set (${PREFIX}_FOUND FALSE) - endif (${i}) - endforeach (i) + # Process all includes and set _FOUND to false if any are missing + foreach(i ${${PREFIX}_PROCESS_INCLUDES}) + if(${i}) + set(${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIRS} ${${i}}) + mark_as_advanced(${i}) + else(${i}) + set(${PREFIX}_FOUND FALSE) + endif(${i}) + endforeach(i) - # Process all libraries and set _FOUND to false if any are missing - foreach (i ${${PREFIX}_PROCESS_LIBS}) - if (${i}) - set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}}) - mark_as_advanced(${i}) - else (${i}) - set (${PREFIX}_FOUND FALSE) - endif (${i}) - endforeach (i) + # Process all libraries and set _FOUND to false if any are missing + foreach(i ${${PREFIX}_PROCESS_LIBS}) + if(${i}) + set(${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARIES} ${${i}}) + mark_as_advanced(${i}) + else(${i}) + set(${PREFIX}_FOUND FALSE) + endif(${i}) + endforeach(i) - # Print message and/or exit on fatal error - if (${PREFIX}_FOUND) - if (NOT ${PREFIX}_FIND_QUIETLY) - message (STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}") - endif (NOT ${PREFIX}_FIND_QUIETLY) - else (${PREFIX}_FOUND) - if (${PREFIX}_FIND_REQUIRED) - foreach (i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS}) - message("${i}=${${i}}") - endforeach (i) - message (FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.") - endif (${PREFIX}_FIND_REQUIRED) - endif (${PREFIX}_FOUND) - endif (NOT ${PREFIX}_FOUND) -endmacro (libfind_process) + # Print message and/or exit on fatal error + if(${PREFIX}_FOUND) + if(NOT ${PREFIX}_FIND_QUIETLY) + message(STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}") + endif(NOT ${PREFIX}_FIND_QUIETLY) + else(${PREFIX}_FOUND) + if(${PREFIX}_FIND_REQUIRED) + foreach(i ${${PREFIX}_PROCESS_INCLUDES} ${${PREFIX}_PROCESS_LIBS}) + message("${i}=${${i}}") + endforeach(i) + message(FATAL_ERROR "Required library ${PREFIX} NOT FOUND.\nInstall the library (dev version) and try again. If the library is already installed, use ccmake to set the missing variables manually.") + endif(${PREFIX}_FIND_REQUIRED) + endif(${PREFIX}_FOUND) + endif(NOT ${PREFIX}_FOUND) +endmacro(libfind_process) macro(libfind_library PREFIX basename) - set(TMP "") - if(MSVC80) - set(TMP -vc80) - endif(MSVC80) - if(MSVC90) - set(TMP -vc90) - endif(MSVC90) - set(${PREFIX}_LIBNAMES ${basename}${TMP}) - if(${ARGC} GREATER 2) - set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2}) - string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES}) - set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP}) - endif(${ARGC} GREATER 2) - find_library(${PREFIX}_LIBRARY - NAMES ${${PREFIX}_LIBNAMES} - PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS} - ) + set(TMP "") + if(MSVC80) + set(TMP -vc80) + endif(MSVC80) + if(MSVC90) + set(TMP -vc90) + endif(MSVC90) + set(${PREFIX}_LIBNAMES ${basename}${TMP}) + if(${ARGC} GREATER 2) + set(${PREFIX}_LIBNAMES ${basename}${TMP}-${ARGV2}) + string(REGEX REPLACE "\\." "_" TMP ${${PREFIX}_LIBNAMES}) + set(${PREFIX}_LIBNAMES ${${PREFIX}_LIBNAMES} ${TMP}) + endif(${ARGC} GREATER 2) + find_library(${PREFIX}_LIBRARY + NAMES ${${PREFIX}_LIBNAMES} + PATHS ${${PREFIX}_PKGCONF_LIBRARY_DIRS} + ) endmacro(libfind_library) - diff --git a/cmake/SelectLibraryConfigurations.cmake b/cmake/SelectLibraryConfigurations.cmake index 205c01d..c413ffc 100644 --- a/cmake/SelectLibraryConfigurations.cmake +++ b/cmake/SelectLibraryConfigurations.cmake @@ -1,5 +1,4 @@ - -# select_library_configurations( basename ) +# select_library_configurations(basename) # # This macro takes a library base name as an argument, and will choose good # values for basename_LIBRARY, basename_LIBRARIES, basename_LIBRARY_DEBUG, and @@ -7,7 +6,7 @@ # basename_LIBRARY_RELEASE is defined, basename_LIBRARY, basename_LIBRARY_DEBUG, # and basename_LIBRARY_RELEASE will be set to the release value. If only # basename_LIBRARY_DEBUG is defined, then basename_LIBRARY, -# basename_LIBRARY_DEBUG and basename_LIBRARY_RELEASE will take the debug value. +# basename_LIBRARY_DEBUG and basename_LIBRARY_RELEASE will take the debug value. # # If the generator supports configuration types, then basename_LIBRARY and # basename_LIBRARIES will be set with debug and optimized flags specifying the @@ -35,48 +34,48 @@ # Utility macro to check if one variable exists while another doesn't, and set # one that doesn't exist to the one that exists. -macro( _set_library_name basename GOOD BAD ) - if( ${basename}_LIBRARY_${GOOD} AND NOT ${basename}_LIBRARY_${BAD} ) - set( ${basename}_LIBRARY_${BAD} ${${basename}_LIBRARY_${GOOD}} ) - set( ${basename}_LIBRARY ${${basename}_LIBRARY_${GOOD}} ) - set( ${basename}_LIBRARIES ${${basename}_LIBRARY_${GOOD}} ) - endif( ${basename}_LIBRARY_${GOOD} AND NOT ${basename}_LIBRARY_${BAD} ) -endmacro( _set_library_name ) +macro(_set_library_name basename GOOD BAD) + if(${basename}_LIBRARY_${GOOD} AND NOT ${basename}_LIBRARY_${BAD}) + set(${basename}_LIBRARY_${BAD} ${${basename}_LIBRARY_${GOOD}}) + set(${basename}_LIBRARY ${${basename}_LIBRARY_${GOOD}}) + set(${basename}_LIBRARIES ${${basename}_LIBRARY_${GOOD}}) + endif(${basename}_LIBRARY_${GOOD} AND NOT ${basename}_LIBRARY_${BAD}) +endmacro(_set_library_name) -macro( select_library_configurations basename ) +macro(select_library_configurations basename) # if only the release version was found, set the debug to be the release # version. - _set_library_name( ${basename} RELEASE DEBUG ) + _set_library_name(${basename} RELEASE DEBUG) # if only the debug version was found, set the release value to be the # debug value. - _set_library_name( ${basename} DEBUG RELEASE ) - if (${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE ) + _set_library_name(${basename} DEBUG RELEASE) + if (${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE) # if the generator supports configuration types or CMAKE_BUILD_TYPE # is set, then set optimized and debug options. - if( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) - set( ${basename}_LIBRARY + if(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + set(${basename}_LIBRARY optimized ${${basename}_LIBRARY_RELEASE} - debug ${${basename}_LIBRARY_DEBUG} ) - set( ${basename}_LIBRARIES + debug ${${basename}_LIBRARY_DEBUG}) + set(${basename}_LIBRARIES optimized ${${basename}_LIBRARY_RELEASE} - debug ${${basename}_LIBRARY_DEBUG} ) - else( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) + debug ${${basename}_LIBRARY_DEBUG}) + else(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) # If there are no configuration types or build type, just use # the release version - set( ${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} ) - set( ${basename}_LIBRARIES ${${basename}_LIBRARY_RELEASE} ) - endif( CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE ) - endif( ${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE ) + set(${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE}) + set(${basename}_LIBRARIES ${${basename}_LIBRARY_RELEASE}) + endif(CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + endif(${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE) - set( ${basename}_LIBRARY ${${basename}_LIBRARY} CACHE FILEPATH - "The ${basename} library" ) + set(${basename}_LIBRARY ${${basename}_LIBRARY} CACHE FILEPATH + "The ${basename} library") - if( ${basename}_LIBRARY ) - set( ${basename}_FOUND TRUE ) - endif( ${basename}_LIBRARY ) + if(${basename}_LIBRARY) + set(${basename}_FOUND TRUE) + endif(${basename}_LIBRARY) - mark_as_advanced( ${basename}_LIBRARY + mark_as_advanced(${basename}_LIBRARY ${basename}_LIBRARY_RELEASE ${basename}_LIBRARY_DEBUG - ) -endmacro( select_library_configurations ) + ) +endmacro(select_library_configurations) diff --git a/cmake/UseCyclus.cmake b/cmake/UseCyclus.cmake index cd2b14e..02fe067 100644 --- a/cmake/UseCyclus.cmake +++ b/cmake/UseCyclus.cmake @@ -1,9 +1,9 @@ # -# The USE_CYCLUS, INSTALL_CYCLUS_STANDALONE, INSTALL_CYCLUS_MODULE macros builds +# The USE_CYCLUS, INSTALL_CYCLUS_STANDALONE, INSTALL_CYCLUS_MODULE macros builds # agent libraries for Cyclus given some source files. # # INSTALL_CYCLUS_STANDALONE is meant to build a single agent into its own -# module. It implicitly calls USE_CYCLUS. For example, +# module. It implicitly calls USE_CYCLUS. For example, # # install_cyclus_standalone("TestFacility" "test_facility" "tests") # @@ -32,10 +32,10 @@ # # Arguments: # lib_root : the root library name, e.g., MyAgent -# src_root : the root name of source files, e.g., my_agent for my_agent.h +# src_root : the root name of source files, e.g., my_agent for my_agent.h # and my_agent.cc # lib_dir : the directory to install the module or agent into. -# test_driver : (optional) the custom test driver to use with unit tests, +# test_driver : (optional) the custom test driver to use with unit tests, # or NONE # # The following vars are updated. @@ -43,7 +43,7 @@ # CYCLUS_LIBRARIES : updated to include _LIB # # The following vars are set. -# +# # _H : the headers used for the agent # _CC : the srcs used for the agent # _TEST_H : the headers used for the agent tests, if it exists @@ -52,241 +52,241 @@ # Target names that are valid: # # _LIB : the name of the library target -# _unit_tests : the name of the unit test executable, if test source +# _unit_tests : the name of the unit test executable, if test source # exists # MACRO(USE_CYCLUS lib_root src_root) - MESSAGE(STATUS "Starting construction of build files for agent: ${src_root}") + MESSAGE(STATUS "Starting construction of build files for agent: ${src_root}") - # output directory - SET(AGENT_PATH "cyclus/${lib_root}") - IF(NOT "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" MATCHES - ".*${AGENT_PATH}$") - SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY - ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${AGENT_PATH}) - ENDIF(NOT "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" MATCHES - ".*${AGENT_PATH}$") + # output directory + SET(AGENT_PATH "cyclus/${lib_root}") + IF(NOT "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" MATCHES + ".*${AGENT_PATH}$") + SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY + ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${AGENT_PATH}) + ENDIF(NOT "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}" MATCHES + ".*${AGENT_PATH}$") - # get preprocessor script - IF(NOT DEFINED CYCPP) - SET(CYCPP "${CYCLUS_CORE_INCLUDE_DIRS}/../../bin/cycpp.py") - ENDIF(NOT DEFINED CYCPP) + # get preprocessor script + IF(NOT DEFINED CYCPP) + SET(CYCPP "${CYCLUS_CORE_INCLUDE_DIRS}/../../bin/cycpp.py") + ENDIF(NOT DEFINED CYCPP) - # make a build directory - SET(BUILD_DIR ${PROJECT_BINARY_DIR}/${lib_root}) - FILE(MAKE_DIRECTORY ${BUILD_DIR}) + # make a build directory + SET(BUILD_DIR ${PROJECT_BINARY_DIR}/${lib_root}) + FILE(MAKE_DIRECTORY ${BUILD_DIR}) - # collect include directories argument - GET_PROPERTY(DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) - SET(INCL_ARGS "-I=") - FOREACH(DIR ${DIRS}) - SET(INCL_ARGS "${INCL_ARGS}:${DIR}") - ENDFOREACH(DIR ${DIRS}) + # collect include directories argument + GET_PROPERTY(DIRS DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) + SET(INCL_ARGS "-I=") + FOREACH(DIR ${DIRS}) + SET(INCL_ARGS "${INCL_ARGS}:${DIR}") + ENDFOREACH(DIR ${DIRS}) - # set cpp path - IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - SET(PREPROCESSOR "--cpp-path=clang++") - ELSE() - SET(PREPROCESSOR "--cpp-path=cpp") - ENDIF() + # set cpp path + IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + SET(PREPROCESSOR "--cpp-path=clang++") + ELSE() + SET(PREPROCESSOR "--cpp-path=cpp") + ENDIF() - # process header - SET(ORIG "--pass3-use-orig") - SET(HIN "${CMAKE_CURRENT_SOURCE_DIR}/${src_root}.h") - SET(HOUT "${BUILD_DIR}/${src_root}.h") - SET(HFLAG "-o=${HOUT}") - SET(CCIN "${CMAKE_CURRENT_SOURCE_DIR}/${src_root}.cc") - SET(CCOUT "${BUILD_DIR}/${src_root}.cc") - SET(CCFLAG "-o=${CCOUT}") + # process header + SET(ORIG "--pass3-use-orig") + SET(HIN "${CMAKE_CURRENT_SOURCE_DIR}/${src_root}.h") + SET(HOUT "${BUILD_DIR}/${src_root}.h") + SET(HFLAG "-o=${HOUT}") + SET(CCIN "${CMAKE_CURRENT_SOURCE_DIR}/${src_root}.cc") + SET(CCOUT "${BUILD_DIR}/${src_root}.cc") + SET(CCFLAG "-o=${CCOUT}") - # not sure if needed.. - IF(NOT EXISTS ${CCOUT}) - MESSAGE(STATUS "Executing ${CYCPP} ${CCIN} ${PREPROCESSOR} ${CCFLAG} ${ORIG} ${INCL_ARGS}") - EXECUTE_PROCESS(COMMAND ${CYCPP} ${CCIN} ${PREPROCESSOR} ${CCFLAG} ${ORIG} ${INCL_ARGS}) - ENDIF(NOT EXISTS ${CCOUT}) - SET( - "${lib_root}_CC" - "${${lib_root}_CC}" "${CCOUT}" - CACHE INTERNAL "Agent impl" FORCE - ) - IF(EXISTS "${HIN}") - # not sure if we still need this... - IF(NOT EXISTS ${HOUT}) - MESSAGE(STATUS "Executing ${CYCPP} ${HIN} ${PREPROCESSOR} ${HFLAG} ${ORIG} ${INCL_ARGS}") - EXECUTE_PROCESS(COMMAND ${CYCPP} ${HIN} ${PREPROCESSOR} ${HFLAG} ${ORIG} ${INCL_ARGS}) - ENDIF(NOT EXISTS ${HOUT}) - ADD_CUSTOM_COMMAND( - OUTPUT ${CCOUT} - OUTPUT ${HOUT} - COMMAND ${CYCPP} ${HIN} ${PREPROCESSOR} ${HFLAG} ${ORIG} ${INCL_ARGS} - COMMAND ${CYCPP} ${CCIN} ${PREPROCESSOR} ${CCFLAG} ${ORIG} ${INCL_ARGS} - DEPENDS ${HIN} - DEPENDS ${CCIN} - DEPENDS ${CYCPP} - COMMENT "Executing ${CYCPP} ${HIN} ${PREPROCESSOR} ${HFLAG} ${ORIG} ${INCL_ARGS}" - COMMENT "Executing ${CYCPP} ${CCIN} ${PREPROCESSOR} ${CCFLAG} ${ORIG} ${INCL_ARGS}" - ) + # not sure if needed.. + IF(NOT EXISTS ${CCOUT}) + MESSAGE(STATUS "Executing ${CYCPP} ${CCIN} ${PREPROCESSOR} ${CCFLAG} ${ORIG} ${INCL_ARGS}") + EXECUTE_PROCESS(COMMAND ${CYCPP} ${CCIN} ${PREPROCESSOR} ${CCFLAG} ${ORIG} ${INCL_ARGS}) + ENDIF(NOT EXISTS ${CCOUT}) SET( - "${lib_root}_H" - "${${lib_root}_H}" "${HOUT}" - CACHE INTERNAL "Agent header" FORCE - ) - ELSE(EXISTS "${HIN}") - ADD_CUSTOM_COMMAND( - OUTPUT ${CCOUT} - COMMAND ${CYCPP} ${CCIN} ${PREPROCESSOR} ${CCFLAG} ${ORIG} ${INCL_ARGS} - DEPENDS ${CCIN} - DEPENDS ${CYCPP} - COMMENT "Executing ${CYCPP} ${CCIN} ${PREPROCESSOR} ${CCFLAG} ${ORIG} ${INCL_ARGS}" - ) - ENDIF(EXISTS "${HIN}") - - # add tests - SET(CCTIN "${CMAKE_CURRENT_SOURCE_DIR}/${src_root}_tests.cc") - SET(CCTOUT "${BUILD_DIR}/${src_root}_tests.cc") - SET(HTIN "${CMAKE_CURRENT_SOURCE_DIR}/${src_root}_tests.h") - SET(HTOUT "${BUILD_DIR}/${src_root}_tests.h") - SET(CMD "cp") - IF(EXISTS "${CCTIN}") - IF(EXISTS "${HTIN}") - # install test headers - MESSAGE(STATUS "Copying ${HTIN} to ${HTOUT}.") - EXECUTE_PROCESS(COMMAND ${CMD} ${HTIN} ${HTOUT}) - ADD_CUSTOM_COMMAND( - OUTPUT ${HTOUT} - OUTPUT ${CCTOUT} - COMMAND ${CMD} ${HTIN} ${HTOUT} - COMMAND ${CMD} ${CCTIN} ${CCTOUT} - DEPENDS ${HIN} - DEPENDS ${CCIN} - DEPENDS ${HTIN} - DEPENDS ${CCTIN} - COMMENT "Copying ${HTIN} to ${HTOUT}." - COMMENT "Copying ${CCTIN} to ${CCTOUT}." + "${lib_root}_CC" + "${${lib_root}_CC}" "${CCOUT}" + CACHE INTERNAL "Agent impl" FORCE ) - SET("${lib_root}_TEST_H" "${${lib_root}_TEST_H}" "${HTOUT}" - CACHE INTERNAL "Agent test headers" FORCE) - ENDIF(EXISTS "${HTIN}") + IF(EXISTS "${HIN}") + # not sure if we still need this... + IF(NOT EXISTS ${HOUT}) + MESSAGE(STATUS "Executing ${CYCPP} ${HIN} ${PREPROCESSOR} ${HFLAG} ${ORIG} ${INCL_ARGS}") + EXECUTE_PROCESS(COMMAND ${CYCPP} ${HIN} ${PREPROCESSOR} ${HFLAG} ${ORIG} ${INCL_ARGS}) + ENDIF(NOT EXISTS ${HOUT}) + ADD_CUSTOM_COMMAND( + OUTPUT ${CCOUT} + OUTPUT ${HOUT} + COMMAND ${CYCPP} ${HIN} ${PREPROCESSOR} ${HFLAG} ${ORIG} ${INCL_ARGS} + COMMAND ${CYCPP} ${CCIN} ${PREPROCESSOR} ${CCFLAG} ${ORIG} ${INCL_ARGS} + DEPENDS ${HIN} + DEPENDS ${CCIN} + DEPENDS ${CYCPP} + COMMENT "Executing ${CYCPP} ${HIN} ${PREPROCESSOR} ${HFLAG} ${ORIG} ${INCL_ARGS}" + COMMENT "Executing ${CYCPP} ${CCIN} ${PREPROCESSOR} ${CCFLAG} ${ORIG} ${INCL_ARGS}" + ) + SET( + "${lib_root}_H" + "${${lib_root}_H}" "${HOUT}" + CACHE INTERNAL "Agent header" FORCE + ) + ELSE(EXISTS "${HIN}") + ADD_CUSTOM_COMMAND( + OUTPUT ${CCOUT} + COMMAND ${CYCPP} ${CCIN} ${PREPROCESSOR} ${CCFLAG} ${ORIG} ${INCL_ARGS} + DEPENDS ${CCIN} + DEPENDS ${CYCPP} + COMMENT "Executing ${CYCPP} ${CCIN} ${PREPROCESSOR} ${CCFLAG} ${ORIG} ${INCL_ARGS}" + ) + ENDIF(EXISTS "${HIN}") + + # add tests + SET(CCTIN "${CMAKE_CURRENT_SOURCE_DIR}/${src_root}_tests.cc") + SET(CCTOUT "${BUILD_DIR}/${src_root}_tests.cc") + SET(HTIN "${CMAKE_CURRENT_SOURCE_DIR}/${src_root}_tests.h") + SET(HTOUT "${BUILD_DIR}/${src_root}_tests.h") + SET(CMD "cp") + IF(EXISTS "${CCTIN}") + IF(EXISTS "${HTIN}") + # install test headers + MESSAGE(STATUS "Copying ${HTIN} to ${HTOUT}.") + EXECUTE_PROCESS(COMMAND ${CMD} ${HTIN} ${HTOUT}) + ADD_CUSTOM_COMMAND( + OUTPUT ${HTOUT} + OUTPUT ${CCTOUT} + COMMAND ${CMD} ${HTIN} ${HTOUT} + COMMAND ${CMD} ${CCTIN} ${CCTOUT} + DEPENDS ${HIN} + DEPENDS ${CCIN} + DEPENDS ${HTIN} + DEPENDS ${CCTIN} + COMMENT "Copying ${HTIN} to ${HTOUT}." + COMMENT "Copying ${CCTIN} to ${CCTOUT}." + ) + SET("${lib_root}_TEST_H" "${${lib_root}_TEST_H}" "${HTOUT}" + CACHE INTERNAL "Agent test headers" FORCE) + ENDIF(EXISTS "${HTIN}") - # install test impl - MESSAGE(STATUS "Copying ${CCTIN} to ${CCTOUT}.") - EXECUTE_PROCESS(COMMAND ${CMD} ${CCTIN} ${CCTOUT}) - ADD_CUSTOM_COMMAND( - OUTPUT ${CCTOUT} - COMMAND ${CMD} ${CCTIN} ${CCTOUT} - DEPENDS ${CCTIN} - DEPENDS ${CCIN} - COMMENT "Copying ${CCTIN} to ${CCTOUT}." - ) - SET("${lib_root}_TEST_CC" "${${lib_root}_TEST_CC}" "${CCOUT}" "${CCTOUT}" - CACHE INTERNAL "Agent test source" FORCE) - ENDIF(EXISTS "${CCTIN}") - MESSAGE(STATUS "Finished construction of build files for agent: ${src_root}") + # install test impl + MESSAGE(STATUS "Copying ${CCTIN} to ${CCTOUT}.") + EXECUTE_PROCESS(COMMAND ${CMD} ${CCTIN} ${CCTOUT}) + ADD_CUSTOM_COMMAND( + OUTPUT ${CCTOUT} + COMMAND ${CMD} ${CCTIN} ${CCTOUT} + DEPENDS ${CCTIN} + DEPENDS ${CCIN} + COMMENT "Copying ${CCTIN} to ${CCTOUT}." + ) + SET("${lib_root}_TEST_CC" "${${lib_root}_TEST_CC}" "${CCOUT}" "${CCTOUT}" + CACHE INTERNAL "Agent test source" FORCE) + ENDIF(EXISTS "${CCTIN}") + MESSAGE(STATUS "Finished construction of build files for agent: ${src_root}") ENDMACRO() MACRO(INSTALL_CYCLUS_STANDALONE lib_root src_root lib_dir) - # clear variables before starting - SET("${lib_root}_H" "" CACHE INTERNAL "Agent header" FORCE) - SET("${lib_root}_CC" "" CACHE INTERNAL "Agent source" FORCE) - SET("${lib_root}_LIB" "" CACHE INTERNAL "Agent library alias." FORCE) - SET("${lib_root}_TEST_H" "" CACHE INTERNAL "Agent test headers" FORCE) - SET("${lib_root}_TEST_CC" "" CACHE INTERNAL "Agent test source" FORCE) - SET("${lib_root}_TEST_LIB" "" CACHE INTERNAL "Agent test library alias." FORCE) + # clear variables before starting + SET("${lib_root}_H" "" CACHE INTERNAL "Agent header" FORCE) + SET("${lib_root}_CC" "" CACHE INTERNAL "Agent source" FORCE) + SET("${lib_root}_LIB" "" CACHE INTERNAL "Agent library alias." FORCE) + SET("${lib_root}_TEST_H" "" CACHE INTERNAL "Agent test headers" FORCE) + SET("${lib_root}_TEST_CC" "" CACHE INTERNAL "Agent test source" FORCE) + SET("${lib_root}_TEST_LIB" "" CACHE INTERNAL "Agent test library alias." FORCE) - # check if a test driver was provided, otherwise use the default - IF(${ARGC} GREATER 3) - SET(DRIVER "${ARGV4}") - ELSE(${ARGC} GREATER 3) - SET(DRIVER "${CYCLUS_DEFAULT_TEST_DRIVER}") - ENDIF(${ARGC} GREATER 3) + # check if a test driver was provided, otherwise use the default + IF(${ARGC} GREATER 3) + SET(DRIVER "${ARGV4}") + ELSE(${ARGC} GREATER 3) + SET(DRIVER "${CYCLUS_DEFAULT_TEST_DRIVER}") + ENDIF(${ARGC} GREATER 3) - USE_CYCLUS("${lib_root}" "${src_root}") - INSTALL_CYCLUS_MODULE("${lib_root}" "${lib_dir}" ${DRIVER}) + USE_CYCLUS("${lib_root}" "${src_root}") + INSTALL_CYCLUS_MODULE("${lib_root}" "${lib_dir}" ${DRIVER}) ENDMACRO() MACRO(INSTALL_CYCLUS_MODULE lib_root lib_dir) - SET(LIB_NAME "${lib_root}") - SET(LIB_SRC "${${lib_root}_CC}") - SET(LIB_H "${${lib_root}_H}") - SET(TEST_SRC "${${lib_root}_TEST_CC}") - SET(TEST_H "${${lib_root}_TEST_H}") - SET(INST_DIR "${lib_dir}") + SET(LIB_NAME "${lib_root}") + SET(LIB_SRC "${${lib_root}_CC}") + SET(LIB_H "${${lib_root}_H}") + SET(TEST_SRC "${${lib_root}_TEST_CC}") + SET(TEST_H "${${lib_root}_TEST_H}") + SET(INST_DIR "${lib_dir}") - # check if a test driver was provided, otherwise use the default - IF(${ARGC} GREATER 2) - SET(DRIVER "${ARGV2}") - ELSE(${ARGC} GREATER 2) - SET(DRIVER "${CYCLUS_DEFAULT_TEST_DRIVER}") - ENDIF(${ARGC} GREATER 2) + # check if a test driver was provided, otherwise use the default + IF(${ARGC} GREATER 2) + SET(DRIVER "${ARGV2}") + ELSE(${ARGC} GREATER 2) + SET(DRIVER "${CYCLUS_DEFAULT_TEST_DRIVER}") + ENDIF(${ARGC} GREATER 2) - INSTALL_AGENT_LIB_("${LIB_NAME}" "${LIB_SRC}" "${LIB_H}" "${INST_DIR}") - INSTALL_AGENT_TESTS_("${LIB_NAME}" "${TEST_SRC}" "${TEST_H}" "${DRIVER}" "${INST_DIR}") + INSTALL_AGENT_LIB_("${LIB_NAME}" "${LIB_SRC}" "${LIB_H}" "${INST_DIR}") + INSTALL_AGENT_TESTS_("${LIB_NAME}" "${TEST_SRC}" "${TEST_H}" "${DRIVER}" "${INST_DIR}") ENDMACRO() MACRO(INSTALL_AGENT_LIB_ lib_name lib_src lib_h inst_dir) - # add lib - ADD_LIBRARY(${lib_name} ${lib_src}) - TARGET_LINK_LIBRARIES(${lib_name} dl ${LIBS}) - SET(CYCLUS_LIBRARIES ${CYCLUS_LIBRARIES} ${lib_root}) - ADD_DEPENDENCIES(${lib_name} ${lib_src} ${lib_h}) + # add lib + ADD_LIBRARY(${lib_name} ${lib_src}) + TARGET_LINK_LIBRARIES(${lib_name} dl ${LIBS}) + SET(CYCLUS_LIBRARIES ${CYCLUS_LIBRARIES} ${lib_root}) + ADD_DEPENDENCIES(${lib_name} ${lib_src} ${lib_h}) - # install library - INSTALL( - TARGETS ${lib_name} - LIBRARY DESTINATION lib/cyclus/${inst_dir} - COMPONENT ${lib_name} - ) - SET(${lib_name}_LIB ${lib_name} CACHE INTERNAL "Agent library alias." FORCE) - - # install headers - IF(NOT "${lib_h}" STREQUAL "") - INSTALL(FILES ${lib_h} DESTINATION include/cyclus COMPONENT "${lib_name}") - ENDIF(NOT "${lib_h}" STREQUAL "") + # install library + INSTALL( + TARGETS ${lib_name} + LIBRARY DESTINATION lib/cyclus/${inst_dir} + COMPONENT ${lib_name} + ) + SET(${lib_name}_LIB ${lib_name} CACHE INTERNAL "Agent library alias." FORCE) + + # install headers + IF(NOT "${lib_h}" STREQUAL "") + INSTALL(FILES ${lib_h} DESTINATION include/cyclus COMPONENT "${lib_name}") + ENDIF(NOT "${lib_h}" STREQUAL "") ENDMACRO() MACRO(INSTALL_AGENT_TESTS_ lib_name test_src test_h driver inst_dir) - # install test header - IF(NOT "${test_h}" STREQUAL "") - INSTALL( - FILES ${test_h} - DESTINATION include/cyclus/${inst_dir} - COMPONENT ${lib_name} - ) - ENDIF(NOT "${test_h}" STREQUAL "") + # install test header + IF(NOT "${test_h}" STREQUAL "") + INSTALL( + FILES ${test_h} + DESTINATION include/cyclus/${inst_dir} + COMPONENT ${lib_name} + ) + ENDIF(NOT "${test_h}" STREQUAL "") - # build & install test impl - IF(NOT "${test_src}" STREQUAL "" AND NOT "${driver}" STREQUAL "NONE") - SET(TGT ${lib_name}_unit_tests) - MESSAGE(STATUS "Building agent unit test binary: ${TGT}") - MESSAGE(STATUS "Using source: ${test_src}") - MESSAGE(STATUS "And test driver: ${driver}") - ADD_EXECUTABLE( - ${TGT} - ${driver} - ${test_src} - ) - TARGET_LINK_LIBRARIES( - ${TGT} dl - ${LIBS} - ${CYCLUS_TEST_LIBRARIES} - ) - INSTALL( - TARGETS ${TGT} - RUNTIME DESTINATION bin - COMPONENT ${lib_name}_testing - ) - ENDIF(NOT "${test_src}" STREQUAL "" AND NOT "${driver}" STREQUAL "NONE") + # build & install test impl + IF(NOT "${test_src}" STREQUAL "" AND NOT "${driver}" STREQUAL "NONE") + SET(TGT ${lib_name}_unit_tests) + MESSAGE(STATUS "Building agent unit test binary: ${TGT}") + MESSAGE(STATUS "Using source: ${test_src}") + MESSAGE(STATUS "And test driver: ${driver}") + ADD_EXECUTABLE( + ${TGT} + ${driver} + ${test_src} + ) + TARGET_LINK_LIBRARIES( + ${TGT} dl + ${LIBS} + ${CYCLUS_TEST_LIBRARIES} + ) + INSTALL( + TARGETS ${TGT} + RUNTIME DESTINATION bin + COMPONENT ${lib_name}_testing + ) + ENDIF(NOT "${test_src}" STREQUAL "" AND NOT "${driver}" STREQUAL "NONE") ENDMACRO() macro(add_all_subdirs) - file(GLOB all_valid_subdirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/CMakeLists.txt") - - foreach(dir ${all_valid_subdirs}) - if(${dir} MATCHES "^([^/]*)//CMakeLists.txt") - string(REGEX REPLACE "^([^/]*)//CMakeLists.txt" "\\1" dir_trimmed ${dir}) - add_subdirectory(${dir_trimmed}) - endif() - endforeach(dir) + file(GLOB all_valid_subdirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/CMakeLists.txt") + + foreach(dir ${all_valid_subdirs}) + if(${dir} MATCHES "^([^/]*)//CMakeLists.txt") + string(REGEX REPLACE "^([^/]*)//CMakeLists.txt" "\\1" dir_trimmed ${dir}) + add_subdirectory(${dir_trimmed}) + endif() + endforeach(dir) endmacro() diff --git a/cmake/cmake_uninstall.cmake.in b/cmake/cmake_uninstall.cmake.in index 4a2a55c..558b4b1 100644 --- a/cmake/cmake_uninstall.cmake.in +++ b/cmake/cmake_uninstall.cmake.in @@ -1,22 +1,22 @@ -if (NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") +if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") message(FATAL_ERROR "Cannot find install manifest: \"@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt\"") endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) string(REGEX REPLACE "\n" ";" files "${files}") list(REVERSE files) -foreach (file ${files}) +foreach(file ${files}) message(STATUS "Uninstalling \"$ENV{DESTDIR}${file}\"") - if (EXISTS "$ENV{DESTDIR}${file}") + if(EXISTS "$ENV{DESTDIR}${file}") execute_process( COMMAND @CMAKE_COMMAND@ -E remove "$ENV{DESTDIR}${file}" OUTPUT_VARIABLE rm_out RESULT_VARIABLE rm_retval - ) + ) if(NOT ${rm_retval} EQUAL 0) message(FATAL_ERROR "Problem when removing \"$ENV{DESTDIR}${file}\"") endif (NOT ${rm_retval} EQUAL 0) - else (EXISTS "$ENV{DESTDIR}${file}") + else(EXISTS "$ENV{DESTDIR}${file}") message(STATUS "File \"$ENV{DESTDIR}${file}\" does not exist.") - endif (EXISTS "$ENV{DESTDIR}${file}") -endforeach(file) \ No newline at end of file + endif(EXISTS "$ENV{DESTDIR}${file}") +endforeach(file) diff --git a/cmake/generate_test_macros.py b/cmake/generate_test_macros.py index a267a5d..74f461f 100644 --- a/cmake/generate_test_macros.py +++ b/cmake/generate_test_macros.py @@ -1,11 +1,11 @@ """generate_test_macros.py -A simple module and default main execution to generate a listing of -ADD_TEST CMake macros for all non-disabled tests in a +A simple module and default main execution to generate a listing of +ADD_TEST CMake macros for all non-disabled tests in a google-test-based executable. -The default main function writes a list of macros to the given output -file. +The default main function writes a list of macros to the given output +file. """ from __future__ import print_function @@ -21,10 +21,10 @@ def parse_tests(test_lines): """Return a list of google test names. - Arguments: + Arguments: - test_lines -- a list of the output of a google test exectuable - using the --gtest_list_tests flag. If the output is in a file, + test_lines -- a list of the output of a google test exectuable + using the --gtest_list_tests flag. If the output is in a file, test_lines are the result of file.readlines(). """ tests = [] @@ -33,21 +33,21 @@ def parse_tests(test_lines): line = test_line.decode().strip() if line[-1] == ".": current_test = line - else: + else: assert current_test is not None if str(line).lower().find("disabled") == -1: - tests.append(current_test + line) + tests.append(current_test + line) return tests def write_macros_to_output(tests, executable, reg_dir, output=None): - """writes a list of test names as ADD_TEST cmake macros to an + """writes a list of test names as ADD_TEST cmake macros to an output file - + Arguments - tests -- a list of all test names to be added as ADD_TEST macros + tests -- a list of all test names to be added as ADD_TEST macros to the output file exectuable -- the name of the test executable - output -- the output file to write to, if output is not + output -- the output file to write to, if output is not specified, the list of ADD_TEST macros will be written to stdout """ lines = [] @@ -69,7 +69,7 @@ def write_macros_to_output(tests, executable, reg_dir, output=None): def main(): description = "A simple script to add CTest ADD_TEST macros to a "+\ - "file for every test in a google-test executable." + "file for every test in a google-test executable." parser = ap.ArgumentParser(description=description) executable = 'the path to the test exectuable to call' @@ -87,11 +87,11 @@ def main(): assert os.path.exists(args.executable) assert os.path.exists(args.output) - rtn = subprocess.Popen([args.executable, "--gtest_list_tests"], + rtn = subprocess.Popen([args.executable, "--gtest_list_tests"], stdout=subprocess.PIPE, shell=(os.name=='nt')) rtn.wait() if rtn.returncode != 0: - raise OSError('Could not generate test list, return code: ' + raise OSError('Could not generate test list, return code: ' + str(rtn.returncode) + '.') tests = parse_tests(rtn.stdout.readlines()) diff --git a/install.py b/install.py index 47c5ee3..dba1439 100755 --- a/install.py +++ b/install.py @@ -51,6 +51,8 @@ def install(args): absexpanduser(args.cmake_prefix_path)] if args.coin_root: cmake_cmd += ['-DCOIN_ROOT_DIR=' + absexpanduser(args.coin_root)] + if args.cyclus_root: + cmake_cmd += ['-DCYCLUS_ROOT_DIR='+absexpanduser(args.cyclus_root)] if args.boost_root: cmake_cmd += ['-DBOOST_ROOT=' + absexpanduser(args.boost_root)] if args.build_type: @@ -69,10 +71,10 @@ def install(args): make_cmd += ['test'] elif not args.build_only: make_cmd += ['install'] - + rtn = subprocess.check_call(make_cmd, cwd=args.build_dir, shell=(os.name == 'nt')) - + def uninstall(args): makefile = os.path.join(args.build_dir, 'Makefile') if not os.path.exists(args.build_dir) or not os.path.exists(makefile): @@ -112,6 +114,9 @@ def main(): coin = "the relative path to the Coin-OR libraries directory" parser.add_argument('--coin_root', help=coin) + cyclus = "the relative path to Cyclus installation directory" + parser.add_argument('--cyclus_root',help=cyclus, default=localdir) + boost = "the relative path to the Boost libraries directory" parser.add_argument('--boost_root', help=boost) @@ -119,7 +124,7 @@ def main(): "FIND_PATH, FIND_PROGRAM, or FIND_LIBRARY macros" parser.add_argument('--cmake_prefix_path', help=cmake_prefix_path) - build_type = "the CMAKE_BUILD_TYPE" + build_type = "the CMAKE_BUILD_TYPE" parser.add_argument('--build_type', help=build_type) args = parser.parse_args()