-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
53 lines (45 loc) · 1.38 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
cmake_minimum_required (VERSION 3.11)
project(socket-sessions)
# Get the source files
file(GLOB sources "src/*.c")
if(ESP_PLATFORM)
if(__idf_component_context)
idf_component_register(
SRCS ${sources}
INCLUDE_DIRS "inc"
)
else()
set(IS_ESP_COMPONENT True)
endif()
else()
if(MSVC)
# ignore warnings about scanf
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_compile_options(/W4 /WX)
else()
add_compile_options(-Wall -Wextra -Werror)
endif()
# Load macrothreading
if(NOT TARGET macrothreading)
include(FetchContent)
FetchContent_Declare(macrothreading_lib
GIT_REPOSITORY https://github.com/gregjesl/macrothreading
)
FetchContent_Populate(macrothreading_lib)
add_subdirectory(${macrothreading_lib_SOURCE_DIR} build)
endif()
# Create the library
add_library(${PROJECT_NAME} ${sources})
# Include directory
target_include_directories(${PROJECT_NAME} PUBLIC inc)
# Link the library
if(NOT TARGET macrothreading)
message(FATAL_ERROR "No macrothreading library found")
endif()
target_link_libraries (${PROJECT_NAME} PUBLIC macrothreading)
# Check for top-level project
if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME})
enable_testing()
add_subdirectory(test)
endif()
endif()