From e2ef019ab5cb80db962a9cfff4da760a5e419743 Mon Sep 17 00:00:00 2001 From: Guilhem Lavaux Date: Tue, 7 Apr 2015 14:45:38 +0200 Subject: [PATCH] Allow to opt-out from yorick classes --- CMakeLists.txt | 19 +++++++++++-------- sample/CMakeLists.txt | 26 ++++++++++++++++---------- src/CMakeLists.txt | 20 +++++++++++++------- 3 files changed, 40 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c4aba78..5689932 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ option(INTERNAL_HDF5 "Build internal version of HDF5" OFF) option(INTERNAL_NETCDF "Build internal version of NETCDF" OFF) option(INTERNAL_BOOST "Build internal version of BOOST" OFF) option(USE_GIT_VERSION "Use GIT version to pad version number" OFF) +option(YORICK_SUPPORT "Add for pleasant yorick support" ON) IF(USE_GIT_VERSION) get_git_head_revision(HEAD GIT_VER) SET(EXTRA_VERSION "-${GIT_VER}") @@ -36,13 +37,15 @@ MESSAGE(STATUS "Using the target ${CosmoTool_local} to build python module") include(${CMAKE_SOURCE_DIR}/external/external_build.cmake) -IF(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") - SET(FOUND_NETCDF4 1) - FILE(WRITE ${CMAKE_BINARY_DIR}/src/ctool_netcdf_ver.hpp "#define NETCDFCPP4 1") -ELSE(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") - SET(FOUND_NETCDF3 1) - FILE(WRITE ${CMAKE_BINARY_DIR}/src/ctool_netcdf_ver.hpp "#undef NETCDFCPP4") -ENDIF(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") +IF(YORICK_SUPPORT) + IF(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") + SET(FOUND_NETCDF4 1) + FILE(WRITE ${CMAKE_BINARY_DIR}/src/ctool_netcdf_ver.hpp "#define NETCDFCPP4 1") + ELSE(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") + SET(FOUND_NETCDF3 1) + FILE(WRITE ${CMAKE_BINARY_DIR}/src/ctool_netcdf_ver.hpp "#undef NETCDFCPP4") + ENDIF(EXISTS ${NETCDFCPP_INCLUDE_PATH}/netcdf AND ${NETCDFCPP_LIBRARY} MATCHES "netcdf_c\\+\\+4") +ENDIF(YORICK_SUPPORT) find_program(CYTHON cython) @@ -52,7 +55,7 @@ endif(HDF5_ROOTDIR) find_package(HDF5 COMPONENTS HL CXX) -set(NETCDF_FIND_REQUIRED TRUE) +set(NETCDF_FIND_REQUIRED ${YORICK_SUPPORT}) set(GSL_FIND_REQUIRED TRUE) FIND_PACKAGE_HANDLE_STANDARD_ARGS(NetCDF DEFAULT_MSG NETCDF_LIBRARY NETCDFCPP_LIBRARY NETCDF_INCLUDE_PATH) FIND_PACKAGE_HANDLE_STANDARD_ARGS(GSL DEFAULT_MSG GSL_LIBRARY GSLCBLAS_LIBRARY GSL_INCLUDE_PATH) diff --git a/sample/CMakeLists.txt b/sample/CMakeLists.txt index dc7ee5a..42fbd2a 100644 --- a/sample/CMakeLists.txt +++ b/sample/CMakeLists.txt @@ -1,7 +1,9 @@ SET(tolink ${GSL_LIBRARIES} ${CosmoTool_local} ${CosmoTool_LIBS}) include_directories(${CMAKE_SOURCE_DIR}/src) -include_directories(${FFTW3_INCLUDE_DIRS} -${EIGEN3_INCLUDE_DIRS} ${NETCDF_INCLUDE_PATH} ${GSL_INCLUDE_PATH}) +include_directories(${FFTW3_INCLUDE_DIRS} ${EIGEN3_INCLUDE_DIRS} ${GSL_INCLUDE_PATH}) +if(YORICK_SUPPORT) + include_directories(${NETCDF_INCLUDE_PATH}) +endif(YORICK_SUPPORT) include_directories(${CMAKE_SOURCE_DIR}/sample) IF(SHARP_INCLUDE_PATH) @@ -63,8 +65,10 @@ if (FFTW3_FOUND AND FFTW3F_FOUND AND EIGEN3_FOUND) IF (FFTW3_LIBRARY_FULL) SET(FFTW3_LIB ${FFTW3_LIB} ${FFTW3_LIBRARY_FULL}) ENDIF (FFTW3_LIBRARY_FULL) - add_executable(test_fft_calls test_fft_calls.cpp) - target_link_libraries(test_fft_calls ${tolink} ${FFTW3_LIB}) + IF(YORICK_SUPPORT) + add_executable(test_fft_calls test_fft_calls.cpp) + target_link_libraries(test_fft_calls ${tolink} ${FFTW3_LIB}) + ENDIF(YORICK_SUPPORT) endif (FFTW3_FOUND AND FFTW3F_FOUND AND EIGEN3_FOUND) if (ENABLE_SHARP AND SHARP_LIBRARY AND SHARP_INCLUDE_PATH AND EIGEN3_FOUND) @@ -81,15 +85,17 @@ target_link_libraries(test_cosmopower ${tolink}) if (Boost_FOUND) include_directories(${Boost_INCLUDE_DIRS}) - add_executable(testSmooth testSmooth.cpp) - target_link_libraries(testSmooth ${tolink}) + IF (YORICK_SUPPORT) + add_executable(testSmooth testSmooth.cpp) + target_link_libraries(testSmooth ${tolink}) - add_executable(simple3DFilter simple3DFilter.cpp) - target_link_libraries(simple3DFilter ${tolink}) + add_executable(simple3DFilter simple3DFilter.cpp) + target_link_libraries(simple3DFilter ${tolink}) + ENDIF (YORICK_SUPPORT) endif (Boost_FOUND) -IF (ENABLE_OPENMP) +IF (ENABLE_OPENMP AND YORICK_SUPPORT) add_executable(gadgetToDensity gadgetToDensity.cpp) target_link_libraries(gadgetToDensity ${tolink}) -ENDIF (ENABLE_OPENMP) +ENDIF (ENABLE_OPENMP AND YORICK_SUPPORT) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ce0aea7..5b0c5b7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -15,13 +15,15 @@ SET(CosmoTool_SRCS IF (ENABLE_OPENMP) ENDIF (ENABLE_OPENMP) -IF(FOUND_NETCDF3) +IF (YORICK_SUPPORT) + IF(FOUND_NETCDF3) SET(CosmoTool_SRCS ${CosmoTool_SRCS} yorick_nc3.cpp) -ELSE(FOUND_NETCDF3) -IF(FOUND_NETCDF4) + ELSE(FOUND_NETCDF3) + IF(FOUND_NETCDF4) SET(CosmoTool_SRCS ${CosmoTool_SRCS} yorick_nc4.cpp) -ENDIF(FOUND_NETCDF4) -ENDIF(FOUND_NETCDF3) + ENDIF(FOUND_NETCDF4) + ENDIF(FOUND_NETCDF3) +ENDIF(YORICK_SUPPORT) if (HDF5_FOUND) @@ -59,9 +61,13 @@ SET(CosmoTool_SRCS ${CosmoTool_SRCS} growthFactor.hpp ) -include_directories(${GSL_INCLUDE_PATH} ${NETCDF_INCLUDE_PATH} ${NETCDFCPP_INCLUDE_PATH} ${CMAKE_BINARY_DIR}/src) +include_directories(${GSL_INCLUDE_PATH} ${CMAKE_BINARY_DIR}/src) -set(CosmoTool_LIBS ${NETCDFCPP_LIBRARY} ${NETCDF_LIBRARY} ${GSL_LIBRARIES}) +set(CosmoTool_LIBS ${GSL_LIBRARIES}) +if(YORICK_SUPPORT) + set(CosmoTool_LIBS ${CosmoTool_LIBS} ${NETCDFCPP_LIBRARY} ${NETCDF_LIBRARY} ${GSL_LIBRARIES}) + include_directories(${NETCDF_INCLUDE_PATH} ${NETCDFCPP_INCLUDE_PATH}) +endif(YORICK_SUPPORT) if (HDF5_FOUND) set(CosmoTool_LIBS ${CosmoTool_LIBS} ${HDF5_CXX_LIBRARIES} ${HDF5_LIBRARIES}) include_directories(${HDF5_INCLUDE_DIRS})