-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
107 lines (92 loc) · 3.1 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
cmake_minimum_required(VERSION 3.14)
project(FlipSolver2d)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
cmake_policy(SET CMP0135 NEW)
endif()
set(FETCHCONTENT_QUIET FALSE)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(MEMORY_SANITIZE OFF CACHE BOOL "Enable memory sanitizer")
set(THREAD_SANITIZE OFF CACHE BOOL "Enable thread sanitizer")
set(ALL_WARNINGS OFF CACHE BOOL "Enable all warnings")
set(POOL_SINGLE_THREAD OFF CACHE BOOL "Force thread pool to single threaded mode")
set(VECTORIZER_DEBUG OFF CACHE BOOL "Enable vectorizer debug")
set(FAST_MATH ON CACHE BOOL "Build with fast math enabled")
set(LINUX_WAYLAND OFF CACHE BOOL "For linux, build for wayland instead of X11")
set(FLUID_ACCEL "avx2" CACHE STRING "SIMD instructions to use. Should only be sse or avx or avx2") #sse, avx, avx2
if(POOL_SINGLE_THREAD)
add_compile_definitions(ENQUEUE_IS_RUN)
endif()
if(UNIX)
add_compile_options(-march=native)
endif()
if(FLUID_ACCEL STREQUAL "sse")
add_compile_definitions(FLUID_SSE)
if(UNIX)
add_compile_options(-msse4.2)
elseif(MSVC)
#no sse flag for msvc
endif()
elseif(FLUID_ACCEL STREQUAL "avx")
add_compile_definitions(FLUID_AVX)
if(UNIX)
add_compile_options(-mavx)
elseif(MSVC)
add_compile_options(/arch:AVX)
endif()
elseif(FLUID_ACCEL STREQUAL "avx2")
add_compile_definitions(FLUID_AVX2)
if(UNIX)
add_compile_options(-mavx2)
elseif(MSVC)
add_compile_options(/arch:AVX2)
endif()
elseif(FLUID_ACCEL STREQUAL "avx512")
#add_compile_definitions(FLUID_512)
message(WARNING "No avx512 support yet")
endif()
if(UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic-errors")
if (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
add_compile_options(-O3)
if(FAST_MATH)
add_compile_options(-ffast-math)
endif()
elseif(CMAKE_BUILD_TYPE STREQUAL "Debug")
#add_compile_options(-Og)
endif()
if(ALL_WARNINGS)
add_compile_options(-Wall -Wextra -Werror=return-type)
endif()
if(MEMORY_SANITIZE)
add_compile_options(-fsanitize=address -fno-omit-frame-pointer)
ADD_LINK_OPTIONS(-fsanitize=address -rdynamic)
endif()
if(THREAD_SANITIZE)
add_compile_options(-fsanitize=thread -fno-omit-frame-pointer)
ADD_LINK_OPTIONS(-fsanitize=thread -rdynamic)
endif()
add_compile_options(-fopenmp)
elseif(MSVC)
if (CMAKE_BUILD_TYPE STREQUAL "Release" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
add_compile_options(/O2)
add_compile_options(/std:c++20)
endif()
add_compile_options(/openmp)
endif()
set(USE_NUMPY_LOGGING ON)
if(USE_NUMPY_LOGGING)
add_compile_definitions(NUMPY_LOGGING)
endif()
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_definitions(DEBUG)
endif()
add_subdirectory(FlipSolver2dLib)
include_directories(FlipSolver2dLib)
include_directories(Utils)
add_subdirectory(Liquid2dRender)
add_subdirectory(bench)
add_subdirectory(AutoBench)
add_subdirectory(Utils)
add_subdirectory(Tests)