-
Notifications
You must be signed in to change notification settings - Fork 16
/
CMakeLists.txt
executable file
·46 lines (36 loc) · 1.23 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
cmake_minimum_required(VERSION 3.20)
project(grpc-c)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 20)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(CMAKE_C_FLAGS " -g -fPIC -fpermissive ")
endif()
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
execute_process(
COMMAND bash -c "git rev-parse HEAD"
OUTPUT_VARIABLE COMMIT_ID
OUTPUT_STRIP_TRAILING_WHITESPACE
)
execute_process(
COMMAND bash -c "git log -1 --format=%cd --date=format:'%Y-%m-%d %H:%M:%S'"
OUTPUT_VARIABLE COMMIT_DATE
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
message("This is a Linux environment.")
add_definitions(-DLINUX)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
message("This is a Windows environment.")
add_definitions(-DWINDOWS)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
message("This is a macOS environment.")
add_definitions(-DDARWIN)
else()
message(FATAL_ERROR "Unsupported operating system: ${CMAKE_SYSTEM_NAME}.")
endif()
set(CMAKE_CXX_FLAGS "${CXX_ONLY_FLAGS} ${CMAKE_CXX_FLAGS}")
message(STATUS "CMAKE_CXX_FLAGS: ${CMAKE_CXX_FLAGS}")
set(CMAKE_INSTALL_PREFIX "publish")
add_subdirectory(lib)
add_subdirectory(compiler)
add_subdirectory(example)