CMakeLists.txt 4.05 KB
Newer Older
1
cmake_minimum_required( VERSION 3.12.4 )
2
project( KiT-RT VERSION 0.1.0 LANGUAGES CXX )
3
4


5
6
7
8
9
10
11
### COMPILER ####################################
set( CMAKE_CXX_STANDARD 17 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( KITRT_RELEASE_OPTIONS -march=native -w )
set( KITRT_RELWITHDEBINFO_OPTIONS -march=native -pg -no-pie )
set( KITRT_DEBUG_OPTIONS -Wall -Wextra -Wpedantic )
#################################################
12

13

14
### LIBRARIES ###################################
15
16
17
18
19
20
21
22
find_package( OpenMP REQUIRED )

find_package( MPI REQUIRED )
include_directories( ${MPI_INCLUDE_PATH} )

find_package( LAPACK REQUIRED )
include_directories( ${LAPACK_INCLUDE_DIR} )

23
find_package( BLAS )
24
25
26
27
28
29
30
31
32

find_package( VTK REQUIRED COMPONENTS vtkIOGeometry vtkFiltersCore )

find_package( Python3 COMPONENTS Interpreter Development NumPy REQUIRED )
include_directories( ${Python3_INCLUDE_DIRS} ${Python3_NumPy_INCLUDE_DIRS} )
add_compile_definitions( KITRT_PYTHON_PATH="${CMAKE_SOURCE_DIR}/python" )

add_compile_definitions( BLAZE_USE_SHARED_MEMORY_PARALLELIZATION=0 )
message( STATUS "Blaze: Shared memory parallelization disabled" )
33
34
35
36
37
38
39
40
if( BLAS_FOUND )
    message( STATUS "Blaze: BLAS mode enabled" )
    add_compile_definitions( BLAZE_BLAS_MODE=1 )
    include_directories( ${BLAS_INCLUDE_DIR} )
else()
    message( STATUS "Blaze: BLAS mode disabled" )
    add_compile_definitions( BLAZE_BLAS_MODE=0 )
endif()
41
include( ${CMAKE_SOURCE_DIR}/cmake/blaze-cache-config.cmake )
42
43
include_directories( ${CMAKE_SOURCE_DIR}/ext/blaze )

Jannick Wolters's avatar
Jannick Wolters committed
44
add_compile_definitions( METIS_EXPORT= )
45
set( DISABLE_PARMETIS_PROGRAMS ON )
46
47
48
49
set( ParMETIS_PATH ${CMAKE_CURRENT_SOURCE_DIR}/ext/parmetis )
include_directories( ${ParMETIS_PATH}/include )
include_directories( ${ParMETIS_PATH}/metis/include )
add_subdirectory( ${ParMETIS_PATH} )
Jannick Wolters's avatar
Jannick Wolters committed
50

51
52
include_directories( ${CMAKE_SOURCE_DIR}/ext/cpptoml/include )
include_directories( ${CMAKE_SOURCE_DIR}/ext/spdlog/include )
53

54
55
56
57
58
set( CORE_LIBRARIES ${Python3_LIBRARIES} ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MPI_LIBRARIES} ${VTK_LIBRARIES} OpenMP::OpenMP_CXX parmetis -lstdc++fs )
#################################################


### MISC ########################################
59
60
61
62
63
64
execute_process(
    COMMAND git rev-parse HEAD
    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
    OUTPUT_VARIABLE GIT_HASH
    OUTPUT_STRIP_TRAILING_WHITESPACE
)
Jannick Wolters's avatar
Jannick Wolters committed
65
add_compile_definitions( GIT_HASH="${GIT_HASH}" )
66
#################################################
67

68

69
70
71
72
### BUILD KIT-RT ################################
file( GLOB_RECURSE SRCS RELATIVE ${CMAKE_SOURCE_DIR} "src/*.cpp" "include/*.h" )
include_directories( ${CMAKE_SOURCE_DIR}/include )
add_executable( ${CMAKE_PROJECT_NAME} ${SRCS} ${EXT_SRCS} )
73
target_link_libraries( ${CMAKE_PROJECT_NAME} ${CORE_LIBRARIES} )
74
75
76
77
78
79
80
81
82
83
set_target_properties( ${CMAKE_PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_SOURCE_DIR}/bin" )
target_compile_options( ${CMAKE_PROJECT_NAME} PUBLIC "$<$<CONFIG:DEBUG>:${KITRT_DEBUG_OPTIONS}>" )
target_compile_options( ${CMAKE_PROJECT_NAME} PUBLIC "$<$<CONFIG:RELWITHDEBINFO>:${KITRT_RELWITHDEBINFO_OPTIONS}>" )
target_compile_options( ${CMAKE_PROJECT_NAME} PUBLIC "$<$<CONFIG:RELEASE>:${KITRT_RELEASE_OPTIONS}>" )
#################################################


### BUILD UNIT TESTS ############################
include( CTest )
set( CATCH_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/ext/Catch2/single_include/catch2 )
84
add_compile_definitions( TESTS_PATH="${CMAKE_SOURCE_DIR}/tests/" )
85
86
87
88
89
90
91
92
93
94
95
96
add_library( Catch INTERFACE )
target_include_directories( Catch INTERFACE ${CATCH_INCLUDE_DIR} )
file( GLOB_RECURSE TEST_SRCS RELATIVE ${CMAKE_SOURCE_DIR} "tests/*.cpp" )
list( REMOVE_ITEM SRCS "src/main.cpp" )
add_executable( unit_tests ${TEST_SRCS} ${SRCS} ${EXT_SRCS} )
target_link_libraries( unit_tests Catch ${CORE_LIBRARIES} )
target_compile_options( unit_tests PUBLIC "$<$<CONFIG:DEBUG>:${KITRT_DEBUG_OPTIONS}>" )
target_compile_options( unit_tests PUBLIC "$<$<CONFIG:RELWITHDEBINFO>:${KITRT_RELWITHDEBINFO_OPTIONS}>" )
target_compile_options( unit_tests PUBLIC "$<$<CONFIG:RELEASE>:${KITRT_RELEASE_OPTIONS}>" )
add_test( NAME unit_tests COMMAND unit_tests )
enable_testing()
#################################################