-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
52 lines (46 loc) · 1.64 KB
/
CMakeLists.txt
File metadata and controls
52 lines (46 loc) · 1.64 KB
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
cmake_minimum_required(VERSION 3.16)
project(HPDE LANGUAGES CXX ASM)
option(HPDE_ENABLE_NATIVE "Enable -march=native on Release builds" ON)
add_library(hpde_core STATIC
src/core.cpp
src/custom_allocator.cpp
)
if(MSVC)
find_program(HPDE_NASM nasm)
if(HPDE_NASM)
set(HPDE_ASM_OBJ ${CMAKE_CURRENT_BINARY_DIR}/assembly.obj)
add_custom_command(
OUTPUT ${HPDE_ASM_OBJ}
COMMAND ${HPDE_NASM} -f win64 -o ${HPDE_ASM_OBJ} ${CMAKE_CURRENT_SOURCE_DIR}/src/assembly.asm
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src/assembly.asm
VERBATIM
)
add_custom_target(hpde_asm_obj ALL DEPENDS ${HPDE_ASM_OBJ})
add_dependencies(hpde_core hpde_asm_obj)
target_sources(hpde_core PRIVATE ${HPDE_ASM_OBJ})
else()
message(FATAL_ERROR "NASM is required on Windows; not found.")
endif()
else()
target_sources(hpde_core PRIVATE src/assembly.S)
endif()
target_include_directories(hpde_core PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/src
)
target_compile_features(hpde_core PUBLIC cxx_std_20)
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU")
target_compile_options(hpde_core PRIVATE
$<$<CONFIG:Release>:-O3>
$<$<AND:$<CONFIG:Release>,$<BOOL:${HPDE_ENABLE_NATIVE}>>:-march=native>
$<$<CONFIG:Release>:-fno-exceptions>
$<$<CONFIG:Release>:-fno-rtti>
)
elseif(MSVC)
target_compile_options(hpde_core PRIVATE
$<$<CONFIG:Release>:/O2>
)
endif()
add_executable(hpde_benchmark src/benchmark.cpp)
find_package(Threads REQUIRED)
target_link_libraries(hpde_core PRIVATE Threads::Threads)
target_link_libraries(hpde_benchmark PRIVATE hpde_core)