forked from pytorch/ELF
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
81 lines (63 loc) · 2.11 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
cmake_minimum_required(VERSION 3.3)
# Basic third-party dependencies
find_package(Threads)
#find_package(Boost REQUIRED COMPONENTS
# thread
#)
#include_directories(${Boost_INCLUDE_DIR})
# Include third-party dependencies
add_subdirectory(
third_party
${CMAKE_CURRENT_BINARY_DIR}/third_party)
find_package(TBB REQUIRED tbb) # Need to find_package in parent scope
# Sanity checks
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
# require at least gcc 7.1
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 7.1)
message(FATAL_ERROR "GCC version must be at least 7.1!")
endif()
endif()
# Variables from Git
execute_process(COMMAND git rev-parse HEAD
OUTPUT_VARIABLE GIT_COMMIT_HASH)
string(STRIP ${GIT_COMMIT_HASH} GIT_COMMIT_HASH)
execute_process(COMMAND git diff-index --quiet HEAD --
RESULT_VARIABLE GIT_UNSTAGED)
if(${GIT_UNSTAGED})
set(GIT_STAGED_STRING unstaged)
else()
set(GIT_STAGED_STRING staged)
endif()
# Global compiler config
set(CMAKE_CXX_STANDARD 17)
set(PYBIND11_CPP_STANDARD -std=c++17)
set(CMAKE_CXX_FLAGS
"${CMAKE_CXX_FLAGS} -Wall -Werror -Wextra -Wno-register -Wno-deprecated-declarations -fPIC -march=native")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
# Define a convenience function for tests
function(add_cpp_tests prefix lib_to_link)
set(test_list ${ARGV})
list(REMOVE_AT test_list 0)
list(REMOVE_AT test_list 0)
foreach(test_file ${test_list})
string(REPLACE "/" "_" test_name ${test_file})
string(REPLACE ".cc" "" test_name ${test_name})
string(CONCAT test_name ${prefix} ${test_name})
add_executable(${test_name} ${test_file})
add_test(${test_name} ${test_name})
target_link_libraries(${test_name} ${lib_to_link} gtest)
endforeach(test_file)
endfunction(add_cpp_tests)
# Include everything in src_cpp
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src_cpp/)
# Main ELF library
add_subdirectory(
src_cpp/elf
${CMAKE_CURRENT_BINARY_DIR}/elf)
# ELF games
add_subdirectory(
src_cpp/elfgames/go
${CMAKE_CURRENT_BINARY_DIR}/elfgames/go)