netgen/libsrc/core/CMakeLists.txt

146 lines
5.3 KiB
CMake
Raw Normal View History

add_library(ngcore ${NGCORE_LIBRARY_TYPE}
2019-07-09 21:07:19 +05:00
archive.cpp
bitarray.cpp
2019-09-23 17:01:35 +05:00
exception.cpp
2019-07-09 21:07:19 +05:00
localheap.cpp
logging.cpp
2019-08-06 17:16:13 +05:00
flags.cpp
2019-07-09 21:07:19 +05:00
paje_trace.cpp
profiler.cpp
2019-08-29 17:21:18 +05:00
table.cpp
2019-07-09 21:07:19 +05:00
taskmanager.cpp
utils.cpp
version.cpp
ng_mpi_wrapper.cpp
2019-07-09 21:07:19 +05:00
)
2018-12-28 17:43:15 +05:00
string(REPLACE "|" ";" ng_compile_flags_replace_sep "${NG_COMPILE_FLAGS}")
2022-09-16 20:13:03 +05:00
target_compile_options(ngcore PUBLIC ${ng_compile_flags_replace_sep})
2023-07-28 16:01:41 +05:00
if(EMSCRIPTEN)
2023-09-05 20:13:29 +05:00
set(PYTHON_MODULE_EXTENSION ".so")
2023-08-28 13:02:22 +05:00
target_link_options(ngcore PUBLIC -sALLOW_MEMORY_GROWTH -sENVIRONMENT=web)
target_compile_options(ngcore PUBLIC -sNO_DISABLE_EXCEPTION_CATCHING)
2023-07-28 16:01:41 +05:00
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# Python packages on Linux are compiled with the old ABI,
# make sure that the same ABI is used in plugins aswell
try_run(
ret_val can_compile
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/_get_glibcxx_use_cxx11_abi.cpp
RUN_OUTPUT_VARIABLE use_glibcxx_cxx11_abi
)
target_compile_definitions(ngcore PUBLIC -D_GLIBCXX_USE_CXX11_ABI=${use_glibcxx_cxx11_abi})
if(USE_PYTHON)
try_run(
ret_val can_compile
${CMAKE_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/_get_gxx_abi.cpp
RUN_OUTPUT_VARIABLE cxx_abi_version
)
if(${can_compile} AND (${ret_val} EQUAL 0))
# Different python modules using pybind11 need to use the same C++ ABI version
# for compatibility
message(STATUS "GNU C++ ABI version: ${cxx_abi_version}")
target_compile_options(ngcore PUBLIC "-fabi-version=${cxx_abi_version}")
endif()
endif(USE_PYTHON)
endif()
2019-08-06 18:50:08 +05:00
if(USE_PYTHON)
target_sources(ngcore PRIVATE python_ngcore.cpp)
target_compile_definitions(ngcore PUBLIC NETGEN_PYTHON NG_PYTHON PYBIND11_SIMPLE_GIL_MANAGEMENT)
2019-08-06 18:50:08 +05:00
endif(USE_PYTHON)
2019-08-28 21:41:42 +05:00
if(WIN32)
2024-03-28 13:51:36 +05:00
target_compile_options(ngcore PUBLIC /bigobj $<BUILD_INTERFACE:/MP;/W1;/wd4068>)
get_WIN32_WINNT(ver)
2021-10-27 19:50:07 +05:00
target_compile_definitions(ngcore PUBLIC _WIN32_WINNT=${ver} WNT WNT_WINDOW NOMINMAX MSVC_EXPRESS _CRT_SECURE_NO_WARNINGS HAVE_STRUCT_TIMESPEC WIN32)
target_link_options(ngcore PUBLIC /ignore:4273 /ignore:4217 /ignore:4049)
else(WIN32)
target_link_libraries(ngcore PUBLIC dl)
2019-08-28 21:41:42 +05:00
endif(WIN32)
target_compile_definitions(ngcore PRIVATE NGCORE_EXPORTS)
target_include_directories(ngcore INTERFACE $<INSTALL_INTERFACE:${NG_INSTALL_DIR_INCLUDE}> $<INSTALL_INTERFACE:${NG_INSTALL_DIR_INCLUDE}/include>)
if(CHECK_RANGE)
target_compile_definitions(ngcore PUBLIC NETGEN_ENABLE_CHECK_RANGE)
endif(CHECK_RANGE)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "DEBUG")
target_compile_definitions(ngcore PUBLIC _DEBUG NETGEN_ENABLE_CHECK_RANGE)
endif(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "DEBUG")
if(TRACE_MEMORY)
target_compile_definitions(ngcore PUBLIC NETGEN_TRACE_MEMORY)
endif(TRACE_MEMORY)
2020-03-25 14:40:12 +05:00
if(USE_NUMA)
find_library(NUMA_LIBRARY libnuma.so)
target_compile_definitions(ngcore PUBLIC USE_NUMA)
target_link_libraries(ngcore PRIVATE ${NUMA_LIBRARY})
endif(USE_NUMA)
install(TARGETS ngcore DESTINATION ${NG_INSTALL_DIR} COMPONENT netgen)
target_link_libraries(ngcore PRIVATE "$<BUILD_INTERFACE:netgen_python>" ${CMAKE_THREAD_LIBS_INIT})
2021-05-30 21:32:42 +05:00
install(FILES ngcore.hpp archive.hpp type_traits.hpp version.hpp ngcore_api.hpp logging.hpp memtracer.hpp
2019-02-12 00:01:07 +05:00
exception.hpp symboltable.hpp paje_trace.hpp utils.hpp profiler.hpp mpi_wrapper.hpp
2019-08-06 17:16:13 +05:00
array.hpp taskmanager.hpp concurrentqueue.h localheap.hpp python_ngcore.hpp flags.hpp
2021-09-06 19:59:48 +05:00
xbool.hpp signal.hpp bitarray.hpp table.hpp hashtable.hpp ranges.hpp ngstream.hpp
2021-01-31 00:05:28 +05:00
simd.hpp simd_avx.hpp simd_avx512.hpp simd_generic.hpp simd_sse.hpp simd_arm64.hpp
2023-09-29 13:56:16 +05:00
register_archive.hpp autodiff.hpp autodiffdiff.hpp
ng_mpi.hpp ng_mpi_generated_declarations.hpp
DESTINATION ${NG_INSTALL_DIR_INCLUDE}/core COMPONENT netgen_devel)
if(ENABLE_CPP_CORE_GUIDELINES_CHECK)
set_target_properties(ngcore PROPERTIES CXX_CLANG_TIDY "${DO_CLANG_TIDY}")
endif(ENABLE_CPP_CORE_GUIDELINES_CHECK)
2018-12-28 17:43:15 +05:00
add_dependencies(ngcore ng_generate_version_file)
2018-12-28 17:43:15 +05:00
if(USE_PYTHON)
pybind11_add_module(pyngcore MODULE python_ngcore_export.cpp)
2024-05-06 15:31:30 +05:00
target_link_libraries(pyngcore PUBLIC ngcore PRIVATE netgen_python)
2022-02-16 13:44:00 +05:00
set_target_properties(pyngcore PROPERTIES INSTALL_RPATH "${NG_RPATH_TOKEN}/../${NETGEN_PYTHON_RPATH}")
2023-09-06 19:27:27 +05:00
if(EMSCRIPTEN)
target_compile_definitions(pyngcore PRIVATE NGCORE_EXPORTS)
endif(EMSCRIPTEN)
install(TARGETS pyngcore DESTINATION ${NG_INSTALL_DIR_PYTHON}/pyngcore COMPONENT netgen)
2018-12-28 17:43:15 +05:00
endif(USE_PYTHON)
2024-05-06 15:31:30 +05:00
function (build_mpi_variant)
set(target ng_${ARGV0})
set(include_dir ${ARGV1})
message("Building MPI variant: ${ARGV0} ${ARGV1}")
add_library(${target} SHARED ng_mpi.cpp)
target_link_libraries(${target} PUBLIC ngcore PRIVATE netgen_python)
target_compile_definitions(${target} PUBLIC PARALLEL)
target_include_directories(${target} PRIVATE ${include_dir})
install(TARGETS ${target} DESTINATION ${NG_INSTALL_DIR_LIB} COMPONENT netgen)
endfunction()
if(USE_MPI)
target_compile_definitions(ngcore PUBLIC PARALLEL)
2024-05-06 15:31:30 +05:00
if(MPI_C_LIBRARY_VERSION_STRING MATCHES "Open MPI.*")
set(OPENMPI_INCLUDE_DIR ${MPI_C_INCLUDE_PATH})
endif()
if(MPI_C_LIBRARY_VERSION_STRING MATCHES "MPICH.*")
set(MPICH_INCLUDE_DIR ${MPI_C_INCLUDE_PATH})
endif()
2024-05-06 15:31:30 +05:00
if(OPENMPI_INCLUDE_DIR)
build_mpi_variant(openmpi ${OPENMPI_INCLUDE_DIR})
endif()
if(MPICH_INCLUDE_DIR)
2024-05-06 15:31:30 +05:00
build_mpi_variant(mpich ${MPICH_INCLUDE_DIR})
endif()
endif(USE_MPI)