-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathCMakeLists.txt
85 lines (75 loc) · 2.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
cmake_minimum_required(VERSION 3.9)
project(isd C)
include_directories(${PROJECT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/light_m4ri/include)
add_executable(isd
light_m4ri/src/matrix.c
src/bits.c
src/dumer.c
src/isd.c
src/sort.c
src/transpose.c
src/xoroshiro128plus.c)
option(PGO "Use Profile-guided optimization (set this option to GEN, then run the executable, then recompile setting this option to USE)" OFF)
foreach(option
"BENCHMARK"
"DUMER_DOOM"
"DUMER_DOOM"
"DUMER_EPS"
"DUMER_L"
"DUMER_LUT"
"DUMER_LUT_SHIFT"
"DUMER_LW"
"DUMER_LW"
"DUMER_P")
if(${option})
target_compile_definitions(isd PUBLIC ${option}=${${option}})
endif()
endforeach()
if (${CMAKE_C_COMPILER_ID} MATCHES "Clang" OR ${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Ofast -march=native -g3")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra")
endif()
if (${CMAKE_C_COMPILER_ID} MATCHES "Clang")
if(${PGO} STREQUAL "GEN")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-instr-generate=build/isd-%p.profraw")
endif()
if(${PGO} STREQUAL "USE")
file(GLOB profraw_list "build/isd-*.profraw")
execute_process(COMMAND llvm-profdata merge -output=build/isd.profdata ${profraw_list})
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-instr-use=isd.profdata")
endif()
elseif (${CMAKE_C_COMPILER_ID} STREQUAL "GNU")
if(${PGO} STREQUAL "GEN")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-generate=build/isd.profdata")
endif()
if(${PGO} STREQUAL "USE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-use=isd.profdata")
endif()
endif()
set_target_properties(isd
PROPERTIES
C_STANDARD 11
C_STANDARD_REQUIRED YES
C_EXTENSIONS YES
)
find_package(OpenMP)
if(OpenMP_C_FOUND)
target_link_libraries(isd PUBLIC OpenMP::OpenMP_C)
endif()
include(CheckIPOSupported)
check_ipo_supported(RESULT ipo_result)
if(ipo_result)
set_target_properties(isd PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
find_library(MATH_LIBRARY m)
if(MATH_LIBRARY)
target_link_libraries(isd PUBLIC ${MATH_LIBRARY})
endif()
file(GLOB_RECURSE ch_list *.c *.h)
add_custom_target(
format
COMMAND clang-format
-i
-verbose
-style=google
${ch_list})