2022-03-31 07:05:04 -04:00
|
|
|
cmake_minimum_required(VERSION 3.14)
|
2017-07-25 12:19:11 -04:00
|
|
|
project(catima)
|
|
|
|
|
|
|
|
############ options #############
|
2022-06-06 14:57:57 -04:00
|
|
|
option(BUILD_SHARED_LIBS "build as shared library" OFF)
|
2019-05-12 14:18:00 -04:00
|
|
|
option(PYTHON_MODULE "compile the Catima python module(requires numpy and cython installed)" OFF)
|
2017-07-25 12:19:11 -04:00
|
|
|
option(TESTS "build tests" OFF)
|
2019-10-22 13:34:09 -04:00
|
|
|
option(EXAMPLES "build examples" OFF)
|
2022-06-08 10:29:19 -04:00
|
|
|
option(APPS "build catima applications" OFF)
|
2018-01-15 09:11:51 -05:00
|
|
|
option(GLOBAL "build with global, sources are required" OFF)
|
2018-07-31 11:40:25 -04:00
|
|
|
option(REACTIONS "enable/disable nuclear reaction rate" ON)
|
2018-10-21 16:08:16 -04:00
|
|
|
option(STORE_SPLINES "store splines, if disables splines are always recreated" ON)
|
|
|
|
option(GSL_INTEGRATION "use GSL integration" OFF)
|
|
|
|
option(GSL_INTERPOLATION "use GSL inteRPOLATION" OFF)
|
|
|
|
option(THIN_TARGET_APPROXIMATION "thin target approximation" ON)
|
2022-04-22 16:52:10 -04:00
|
|
|
option(ET_CALCULATED_INDEX "calculate energy table index, otherwise search" ON)
|
2018-10-21 16:08:16 -04:00
|
|
|
option(GENERATE_DATA "make data tables generator" OFF)
|
2021-05-19 10:17:29 -04:00
|
|
|
option(PYTHON_WHEEL "make python wheel" OFF)
|
2017-07-25 12:19:11 -04:00
|
|
|
######## build type ############
|
2018-10-18 20:51:01 -04:00
|
|
|
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
|
|
|
|
set(CMAKE_BUILD_TYPE "Release")
|
2022-04-22 16:52:10 -04:00
|
|
|
#set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -ffast-math")
|
2018-10-18 20:51:01 -04:00
|
|
|
MESSAGE(STATUS "Build type Release")
|
|
|
|
else()
|
2022-04-22 16:52:10 -04:00
|
|
|
#set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -g")
|
2018-10-18 20:51:01 -04:00
|
|
|
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" OR ${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
|
2018-10-21 16:08:16 -04:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -Wextra -Wfatal-errors -Wno-unused-parameter -Wno-sign-compare")
|
2018-10-18 20:51:01 -04:00
|
|
|
endif()
|
|
|
|
MESSAGE(STATUS "Build type Debug")
|
|
|
|
endif()
|
|
|
|
MESSAGE(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
|
2017-07-25 12:19:11 -04:00
|
|
|
################################
|
|
|
|
|
|
|
|
######### compiler flags ###########
|
2022-06-08 10:29:19 -04:00
|
|
|
set(CMAKE_CXX_STANDARD 17)
|
2017-07-25 12:19:11 -04:00
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
2018-10-18 20:51:01 -04:00
|
|
|
MESSAGE(STATUS "install prefix: " ${CMAKE_INSTALL_PREFIX})
|
2017-07-25 12:19:11 -04:00
|
|
|
|
2017-09-22 06:05:35 -04:00
|
|
|
if(APPLE)
|
|
|
|
set(RPATH_VARIABLE "DYLD_LIBRARY_PATH")
|
|
|
|
else()
|
|
|
|
set(RPATH_VARIABLE "LD_LIBRARY_PATH")
|
|
|
|
endif()
|
|
|
|
|
2017-07-25 12:19:11 -04:00
|
|
|
############# Requirements ##################
|
2018-10-21 16:08:16 -04:00
|
|
|
if(GSL_INTEGRATION OR GSL_INTERPOLATION)
|
|
|
|
find_package(GSL REQUIRED)
|
|
|
|
MESSAGE(STATUS "GSL include dirs: " ${GSL_INCLUDE_DIRS})
|
|
|
|
list(APPEND EXTRA_LIBS ${GSL_LIBRARIES} )
|
2017-07-25 12:19:11 -04:00
|
|
|
endif()
|
|
|
|
|
2018-04-29 18:16:45 -04:00
|
|
|
|
2022-03-31 07:05:04 -04:00
|
|
|
configure_file( "${CMAKE_CURRENT_SOURCE_DIR}/build_config.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/include/catima/build_config.h")
|
2017-07-25 12:19:11 -04:00
|
|
|
|
|
|
|
configure_file("${PROJECT_SOURCE_DIR}/init.sh.in"
|
2022-03-31 07:05:04 -04:00
|
|
|
"${PROJECT_BINARY_DIR}/init.sh")
|
2017-07-25 12:19:11 -04:00
|
|
|
############### main build ###########################
|
|
|
|
|
2022-06-08 11:20:02 -04:00
|
|
|
file(GLOB SOURCES catima/*.cpp)
|
2018-01-15 09:11:51 -05:00
|
|
|
if(GLOBAL)
|
|
|
|
file(GLOB GLOBAL_SOURCES global/*.c)
|
|
|
|
LIST (APPEND SOURCES ${GLOBAL_SOURCES})
|
|
|
|
endif(GLOBAL)
|
2022-06-08 11:20:02 -04:00
|
|
|
file(GLOB HEADERS catima/*.h libs/*.h)
|
2018-01-24 08:21:28 -05:00
|
|
|
|
2018-10-22 18:04:01 -04:00
|
|
|
add_library(catima ${SOURCES})
|
2018-04-18 09:19:03 -04:00
|
|
|
set_target_properties(catima PROPERTIES
|
2022-04-22 16:52:10 -04:00
|
|
|
POSITION_INDEPENDENT_CODE ON
|
|
|
|
LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
|
|
|
|
ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib
|
2018-04-18 09:19:03 -04:00
|
|
|
)
|
2018-10-21 16:08:16 -04:00
|
|
|
|
2022-03-29 05:19:50 -04:00
|
|
|
target_link_libraries(catima PUBLIC ${EXTRA_LIBS})
|
2022-03-29 08:58:07 -04:00
|
|
|
target_compile_features(catima PRIVATE cxx_std_17)
|
2019-10-22 13:34:09 -04:00
|
|
|
target_include_directories(catima
|
2018-01-24 08:21:28 -05:00
|
|
|
PUBLIC $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include>
|
|
|
|
$<BUILD_INTERFACE:${GSL_INCLUDE_DIRS}>
|
|
|
|
)
|
2018-10-21 16:08:16 -04:00
|
|
|
|
2018-04-17 19:19:29 -04:00
|
|
|
add_library(catima::catima ALIAS catima)
|
2018-01-24 08:21:28 -05:00
|
|
|
|
2017-07-25 12:19:11 -04:00
|
|
|
FILE(COPY ${HEADERS} DESTINATION ${PROJECT_BINARY_DIR}/include/catima)
|
|
|
|
|
2019-10-22 13:34:09 -04:00
|
|
|
# the compiler used for C++ files
|
2017-07-25 12:19:11 -04:00
|
|
|
MESSAGE( STATUS "CMAKE_CXX_COMPILER: " ${CMAKE_CXX_COMPILER} )
|
|
|
|
|
2022-03-31 07:05:04 -04:00
|
|
|
######## for python module #########
|
2021-05-17 11:03:38 -04:00
|
|
|
find_package(Python COMPONENTS Interpreter Development)
|
|
|
|
if(Python_FOUND)
|
|
|
|
message(STATUS "Python found: ${Python_EXECUTABLE}")
|
2018-10-21 16:08:16 -04:00
|
|
|
endif()
|
2018-08-13 12:08:54 -04:00
|
|
|
if(PYTHON_MODULE)
|
2021-05-17 11:03:38 -04:00
|
|
|
if(NOT Python_FOUND)
|
2019-10-22 13:34:09 -04:00
|
|
|
MESSAGE(SEND_ERROR "Python is required to build nurex python modules")
|
2021-05-17 11:03:38 -04:00
|
|
|
endif(NOT Python_FOUND)
|
2021-05-17 09:49:00 -04:00
|
|
|
find_package(pybind11 QUIET)
|
|
|
|
if(NOT pybind11_FOUND)
|
2022-03-29 08:58:07 -04:00
|
|
|
message("pybind11 not found, trying to dowload")
|
2021-05-17 16:58:40 -04:00
|
|
|
include(FetchContent)
|
|
|
|
FetchContent_Declare(
|
|
|
|
pybind11
|
|
|
|
GIT_REPOSITORY https://github.com/pybind/pybind11.git
|
|
|
|
GIT_TAG v2.6.2
|
|
|
|
)
|
|
|
|
FetchContent_MakeAvailable(pybind11)
|
2021-05-17 09:49:00 -04:00
|
|
|
endif(NOT pybind11_FOUND)
|
|
|
|
|
2022-04-22 16:52:10 -04:00
|
|
|
check_fmt()
|
2021-05-17 09:49:00 -04:00
|
|
|
#set(PYBIND11_CPP_STANDARD -std=c++14)
|
2021-06-18 10:50:30 -04:00
|
|
|
pybind11_add_module(pycatima pymodule/pycatima.cpp)
|
2019-05-12 14:14:53 -04:00
|
|
|
target_include_directories(pycatima PUBLIC
|
|
|
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/include>
|
|
|
|
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/libs>
|
|
|
|
$<INSTALL_INTERFACE:include>)
|
2022-03-31 07:05:04 -04:00
|
|
|
target_link_libraries(pycatima PRIVATE catima fmt::fmt)
|
2018-08-13 12:08:54 -04:00
|
|
|
endif(PYTHON_MODULE )
|
2022-03-31 07:05:04 -04:00
|
|
|
|
|
|
|
configure_file("${PROJECT_SOURCE_DIR}/pymodule/setup.py.in" "${PROJECT_BINARY_DIR}/setup.py")
|
2021-05-19 10:17:29 -04:00
|
|
|
if(PYTHON_WHEEL)
|
2022-04-22 16:52:10 -04:00
|
|
|
check_fmt()
|
2022-03-31 07:05:04 -04:00
|
|
|
execute_process(COMMAND ${Python_EXECUTABLE} ${PROJECT_BINARY_DIR}/setup.py bdist_wheel)
|
2021-05-19 10:17:29 -04:00
|
|
|
endif(PYTHON_WHEEL)
|
2017-07-25 12:19:11 -04:00
|
|
|
|
|
|
|
########## Sub Directories ###########
|
|
|
|
if(EXAMPLES)
|
|
|
|
file(GLOB EXAMPLES examples/*.cpp)
|
|
|
|
FILE(COPY ${EXAMPLES} DESTINATION ${PROJECT_BINARY_DIR}/examples)
|
|
|
|
FILE(COPY examples/makefile DESTINATION ${PROJECT_BINARY_DIR}/examples)
|
|
|
|
#add_subdirectory("examples")
|
|
|
|
endif(EXAMPLES)
|
|
|
|
if(TESTS)
|
2018-07-31 11:40:25 -04:00
|
|
|
enable_testing()
|
2017-07-25 12:19:11 -04:00
|
|
|
add_subdirectory("tests")
|
|
|
|
endif(TESTS)
|
|
|
|
|
|
|
|
########## data generator ########
|
|
|
|
if(GENERATE_DATA)
|
|
|
|
add_executable(generate_ls_coeff utils/generator.cpp)
|
|
|
|
target_link_libraries(generate_ls_coeff catima)
|
|
|
|
#add_custom_command(
|
|
|
|
# OUTPUT ${CMAKE_CURRENT_BINARY_DIR/include/generated_LS_coeff.h}
|
2019-10-22 13:34:09 -04:00
|
|
|
# COMMAND
|
2017-07-25 12:19:11 -04:00
|
|
|
#)
|
|
|
|
endif(GENERATE_DATA)
|
|
|
|
|
2018-04-12 19:12:45 -04:00
|
|
|
###### subdirectories ######
|
|
|
|
if(APPS)
|
|
|
|
add_subdirectory("bin")
|
|
|
|
endif(APPS)
|
|
|
|
|
2017-07-25 12:19:11 -04:00
|
|
|
####### install part #######
|
2022-06-08 11:20:02 -04:00
|
|
|
FILE(GLOB headers "catima/*.h")
|
2018-04-17 19:19:29 -04:00
|
|
|
include(GNUInstallDirs)
|
2022-03-29 05:19:50 -04:00
|
|
|
include(CMakePackageConfigHelpers)
|
|
|
|
|
|
|
|
write_basic_package_version_file(catimaConfigVersion.cmake VERSION 1.7 COMPATIBILITY AnyNewerVersion)
|
|
|
|
|
2018-10-21 16:08:16 -04:00
|
|
|
install (TARGETS catima
|
2018-04-17 19:19:29 -04:00
|
|
|
EXPORT catimaConfig
|
|
|
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
|
|
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
2019-10-22 13:34:09 -04:00
|
|
|
|
2017-07-25 12:19:11 -04:00
|
|
|
install (FILES ${headers} DESTINATION include/catima)
|
|
|
|
|
2018-04-17 19:19:29 -04:00
|
|
|
install(EXPORT catimaConfig
|
|
|
|
NAMESPACE catima::
|
|
|
|
DESTINATION lib/cmake/catima
|
|
|
|
)
|
2019-10-22 13:34:09 -04:00
|
|
|
|
2018-10-21 16:08:16 -04:00
|
|
|
export(TARGETS catima NAMESPACE catima:: FILE catimaConfig.cmake)
|
2018-04-17 19:19:29 -04:00
|
|
|
export(PACKAGE catima)
|
|
|
|
|
2017-07-25 12:19:11 -04:00
|
|
|
###### packaging #######
|
|
|
|
set(CPACK_PACKAGE_NAME "catima")
|
|
|
|
set(CPACK_PACKAGE_VENDOR "A. Prochazka")
|
|
|
|
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "")
|
|
|
|
set(CPACK_PACKAGE_VERSION "1.0.0")
|
|
|
|
set(CPACK_PACKAGE_VERSION_MAJOR "1")
|
|
|
|
set(CPACK_PACKAGE_VERSION_MINOR "0")
|
|
|
|
set(CPACK_PACKAGE_VERSION_PATCH "0")
|
|
|
|
set(CPACK_PACKAGE_INSTALL_DIRECTORY "catima")
|
|
|
|
include(CPack)
|