-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
66 lines (52 loc) · 1.91 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
cmake_minimum_required(VERSION 3.21)
set(PROJECT NIAHttpBOT)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_BUILD_TYPE Release)
project(${PROJECT})
cmake_host_system_information(RESULT CPU_CORES_FIGURE QUERY NUMBER_OF_LOGICAL_CORES)
if(NOT CMAKE_CXX_COMPILER_LOADED)
message(FATAL_ERROR, "You should use C++ compiler instead of C")
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
if(CMAKE_COMPILER_IS_GNUCXX)
set(LINK_LIBRARIES_FLAG ws2_32 crypt32 cryptui)
set(AVX2_FLAG -mavx2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast") # -march=native
message("linked ws2_32, crypt32, cryptui for httplib.h")
else()
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
set(AVX2_FLAG /arch:AVX2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ")
add_compile_options($<$<CXX_COMPILER_ID:MSVC>:/MP${CPU_CORES_FIGURE}>)
endif()
if(MSVC)
add_compile_options("/utf-8")
endif()
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(AVX2_FLAG -mavx2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Ofast")
endif()
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("${AVX2_FLAG}" SUPPORTS_AVX2)
if(SUPPORTS_AVX2)
message("-> enable AVX2 (\"${AVX2_FLAG}\")")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${AVX2_FLAG}")
endif()
aux_source_directory(./src/ SOURCE)
include_directories(./header)
add_definitions(-D__PROJECT__="${CMAKE_CURRENT_SOURCE_DIR}")
add_executable(${PROJECT} ${SOURCE})
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
target_link_libraries(${PROJECT} PRIVATE
"${CMAKE_SOURCE_DIR}/lib/libcrypto.lib"
"${CMAKE_SOURCE_DIR}/lib/libssl.lib")
add_custom_command(TARGET ${PROJECT} POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
"${CMAKE_SOURCE_DIR}/lib/libssl-3-x64.dll"
"$<TARGET_FILE_DIR:${PROJECT}>/libssl-3-x64.dll"
COMMAND ${CMAKE_COMMAND} -E copy
"${CMAKE_SOURCE_DIR}/lib/libcrypto-3-x64.dll"
"$<TARGET_FILE_DIR:${PROJECT}>/libcrypto-3-x64.dll"
COMMENT "Copying dll to executable directory")
endif()