-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
110 lines (96 loc) · 3.19 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
# # Set MSYS generator
# set(CMAKE_GENERATOR "MSYS Makefiles")
# message(STATUS "generator is set to ${CMAKE_GENERATOR}")
# Project information
project(CAFEA
VERSION 2.1.0
DESCRIPTION "In-house FEA program"
LANGUAGES CXX)
# Set for CXX standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Set Fortran language
if(MSYS OR MINGW OR UNIX)
enable_language(Fortran)
message(STATUS "Add Fortran language")
endif()
# Find OpenMP for Eigen3
find_package(OpenMP REQUIRED)
if(OpenMP_FOUND)
message(STATUS "Find OpenMP")
else()
message(STATUS "Cannot find OpenMP")
endif()
if(NOT MSVC)
# Find Eigen3
find_package(Eigen3 3.3 CONFIG)
# find_package(Eigen3 3.3 CONFIG REQUIRED)
# Find fmt
find_package(fmt 5.3 CONFIG)
# Find Catch2
find_package(Catch2 2.9.2 CONFIG)
endif()
# When some aformentioned libraries cannot found.
# Then download source from web.
add_subdirectory(extern)
add_library(src OBJECT
src/base/load.cc
src/base/material.cc
src/base/section.cc
src/base/dof_handler.cc
src/base/node.cc
src/core/coord_tran.cc
src/element/element_attr.cc
src/element/element.cc
src/element/additional.cc
src/element/pipe.cc)
if(MSVC)
if(TARGET Eigen3::Eigen)
message(STATUS "Eigen3 intsalled")
else()
message(STATUS "${Eigen3_SOURCE_DIR} ${Eigen3_BINARY_DIR}")
endif()
if(TARGET fmt::fmt)
message(STATUS "fmt installed")
else()
message(STATUS "${fmt_SOURCE_DIR} ${fmt_BINARY_DIR}")
endif()
if(TARGET Catch2::Catch2)
message(STATUS "Catch2 installed")
else()
message(STATUS "${Catch2_SOURCE_DIR} ${Catch2_BINARY_DIR}")
endif()
target_include_directories(src PUBLIC src/include ${Eigen3_SOURCE_DIR} ${fmt_SOURCE_DIR}/include)
target_link_libraries(src PUBLIC OpenMP::OpenMP_CXX fmt::fmt)
else()
target_include_directories(src PUBLIC src/include)
target_link_libraries(src PUBLIC OpenMP::OpenMP_CXX Eigen3::Eigen fmt::fmt)
endif()
# add_executable(gauss test/test_utility_01.cc)
# target_include_directories(gauss PUBLIC src/include)
# target_link_libraries(gauss PUBLIC Eigen3::Eigen OpenMP::OpenMP_CXX fmt::fmt )
if(MSVC)
add_compile_options(/W4 /WX)
else()
add_compile_options(-Wall -Wextra -Werror -pedantic $<$<CONFIG:Release>:-O3>)
endif()
enable_testing()
# include(CTest)
set(CMAKE_MODULE_PATH ${Catch2_SOURCE_DIR}/contrib ${CMAKE_MODULE_PATH})
include(Catch)
foreach(loopVar RANGE 1 10)
if(${loopVar} GREATER 9)
set(tName a${loopVar})
else()
set(tName a0${loopVar})
endif()
message(STATUS "**** Add test: ${tName}")
add_executable(${tName} test/basic/${tName}.cc)
target_include_directories(${tName} PUBLIC src/include ${Catch2_SOURCE_DIR}/single_include/catch2)
target_link_libraries(${tName} PRIVATE src)
# target_link_libraries(${tName} PRIVATE src PUBLIC Catch2::Catch2)
# add_test(NAME ${tName} COMMAND ${tName} --success)
catch_discover_tests(${tName})
endforeach()