-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCMakeLists.txt
49 lines (40 loc) · 1.82 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
cmake_minimum_required(VERSION 3.5)
project(BITS)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif ()
MESSAGE(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
if (NOT TARGET BITS)
add_library(BITS INTERFACE)
target_include_directories(BITS INTERFACE .)
target_include_directories(BITS INTERFACE ./include)
target_compile_features(BITS INTERFACE cxx_std_17)
MESSAGE(STATUS "Compiling for processor: " ${CMAKE_HOST_SYSTEM_PROCESSOR})
if (UNIX AND (CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "x86_64"))
MESSAGE(STATUS "Compiling with flags: -march=native -mbmi2 -msse4.2")
target_compile_options(BITS INTERFACE -march=native)
target_compile_options(BITS INTERFACE -mbmi2 -msse4.2) # for hardware popcount and pdep
endif()
if (UNIX)
target_compile_options(BITS INTERFACE -ggdb)
target_compile_options(BITS INTERFACE -Wall -Wextra -Wno-missing-braces -Wno-unknown-attributes -Wno-unused-function)
if (BITS_USE_SANITIZERS)
MESSAGE(STATUS "Using sanitizers. Compiling with flags: -fsanitize=address -fno-omit-frame-pointer")
target_compile_options(BITS INTERFACE -fsanitize=address -fno-omit-frame-pointer)
endif()
endif()
add_subdirectory(external/essentials)
target_link_libraries(BITS INTERFACE ESSENTIALS)
endif()
# Only add benchmarks and tests when compiling BITS itself, not when added as a dependency
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
enable_testing()
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
file(GLOB TEST_SOURCES test/test_*.cpp)
foreach(TEST_SRC ${TEST_SOURCES})
get_filename_component (TEST_SRC_NAME ${TEST_SRC} NAME_WE) # without extension
add_executable(${TEST_SRC_NAME} ${TEST_SRC})
add_test(${TEST_SRC_NAME} ${TEST_SRC_NAME})
target_link_libraries(${TEST_SRC_NAME} PRIVATE BITS)
endforeach(TEST_SRC)
endif()