-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
70 lines (63 loc) · 2.53 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
cmake_minimum_required(VERSION 3.10)
if(NOT WIN32)
string(ASCII 27 Esc)
set(ColourReset "${Esc}[m")
set(ColourBold "${Esc}[1m")
set(Red "${Esc}[31m")
set(Green "${Esc}[92m")
set(Yellow "${Esc}[33m")
set(Blue "${Esc}[34m")
set(Magenta "${Esc}[35m")
set(Cyan "${Esc}[36m")
set(White "${Esc}[37m")
set(BoldRed "${Esc}[1;31m")
set(BoldGreen "${Esc}[1;32m")
set(BoldYellow "${Esc}[1;33m")
set(BoldBlue "${Esc}[1;34m")
set(BoldMagenta "${Esc}[1;35m")
set(BoldCyan "${Esc}[1;36m")
set(BoldWhite "${Esc}[1;37m")
endif()
if(CMAKE_CURRENT_BINARY_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
message(FATAL_ERROR "${Red}In-source builds are not allowed.${ColourReset}")
endif()
project(Cengine)
set(CMAKE_CXX_STANDARD 20)
set(CXX_STANDARD 20)
if(NOT CMAKE_BUILD_TYPE)
message("${Yellow}Build type not specified, assuming Release mode${ColourReset}")
set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS True)
file(GLOB libcengine_src "src/*.hpp" "src/*.cpp")
list(REMOVE_ITEM libcengine_src "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp")
list(REMOVE_ITEM libcengine_src "${CMAKE_CURRENT_SOURCE_DIR}/src/thread_pool_test.cpp")
#message("${libcengine_src}")
try_compile(POPCNT "${CMAKE_BINARY_DIR}" "${CMAKE_SOURCE_DIR}/checks/popcount_support.cpp" COMPILE_DEFINITIONS -march=native)
set(BMI_MACROS "")
if(POPCNT)
message("${Green}Supports popcnt...${ColourReset}")
set (BMI_MACROS "${BMI_MACROS} -DUSE_POPCNT")
else()
message("${Red}Doesn't support popcnt...${ColourReset}")
endif()
try_compile(PEXT "${CMAKE_BINARY_DIR}" "${CMAKE_SOURCE_DIR}/checks/pext_support.cpp" COMPILE_DEFINITIONS -march=native)
if(PEXT)
message("${Green}Supports pext...${ColourReset}")
#set (BMI_MACROS "${BMI_MACROS} -DUSE_PEXT")
else()
message("${Red}Doesn't support pext...${ColourReset}")
endif()
if(NOT EMSCRIPTEN)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wno-narrowing -fopenmp -march=native")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${BMI_MACROS} -Wno-narrowing -march=native -fopenmp")
endif()
add_library(libcengine STATIC ${libcengine_src})
add_executable(cengine "src/main.cpp")
target_link_libraries(cengine PUBLIC libcengine)
#add_executable(tptest "src/thread_pool.cpp" "src/thread_pool_test.cpp" "src/bitboard.cpp" "src/position.cpp")
#target_link_libraries(cengine gomp)
add_custom_target( FinalMessage ALL
${CMAKE_COMMAND} -E cmake_echo_color --cyan "Building ${CMAKE_BUILD_TYPE} is over!"
COMMENT "Final Message" )
add_dependencies(FinalMessage cengine)