diff --git a/CMakeLists.txt b/CMakeLists.txt index 4e0ea3a..f12616a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ include(GetGitRevisionDescription) get_git_head_revision(HEAD GIT_VER) option(BUILD_SHARED_LIBS "Build shared libraries." OFF) +option(BUILD_STATIC_LIBS "Build static libraries." ON) find_path(NETCDF_INCLUDE_PATH NAMES netcdf.h) find_path(GSL_INCLUDE_PATH NAMES gsl/gsl_blas.h) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 183e96b..55f3318 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -16,6 +16,10 @@ if (HDF5_FOUND) h5_readFlash.cpp loadFlash.cpp ) +else(HDF5_FOUND) + set(CosmoTool_SRCS ${CosmoTool_SRCS} + loadFlash_dummy.cpp + ) endif (HDF5_FOUND) SET(CosmoTool_SRCS ${CosmoTool_SRCS} @@ -43,7 +47,6 @@ SET(CosmoTool_SRCS ${CosmoTool_SRCS} ) include_directories(${GSL_INCLUDE_PATH} ${NETCDF_INCLUDE_PATH}) -add_library(CosmoTool ${CosmoTool_SRCS}) set(CosmoTool_LIBS ${NETCDF_LIBRARY} ${NETCDFCPP_LIBRARY} ${GSL_LIBRARY} ${GSLCBLAS_LIBRARY}) if (HDF5_FOUND) @@ -51,12 +54,27 @@ if (HDF5_FOUND) include_directories(${HDF5_INCLUDE_DIRS}) endif (HDF5_FOUND) -target_link_libraries(CosmoTool ${CosmoTool_LIBS}) +if (BUILD_SHARED_LIBS) + add_library(CosmoTool SHARED ${CosmoTool_SRCS}) + target_link_libraries(CosmoTool ${CosmoTool_LIBS}) + if (BUILD_STATIC_LIBS) + add_library(CosmoTool_static STATIC ${CosmoTool_SRCS}) + endif(BUILD_STATIC_LIBS) +else (BUILD_SHARED_LIBS) + add_library(CosmoTool STATIC ${CosmoTool_LIBS}) +endif (BUILD_SHARED_LIBS) install(TARGETS CosmoTool LIBRARY DESTINATION lib ARCHIVE DESTINATION lib) + +if (BUILD_SHARED_LIBS) + install(TARGETS CosmoTool_static + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib) +endif (BUILD_SHARED_LIBS) + install(DIRECTORY . DESTINATION include/CosmoTool FILES_MATCHING PATTERN "*.hpp") install(DIRECTORY . DESTINATION include/CosmoTool