-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
65 lines (54 loc) · 1.83 KB
/
CMakeLists.txt
File metadata and controls
65 lines (54 loc) · 1.83 KB
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
cmake_minimum_required(VERSION 3.15)
project(hey)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
#include(CheckIPOSupported)
#check_ipo_supported(RESULT IPO_SUPPORTED)
#if (IPO_SUPPORTED)
#set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
#set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE)
#endif ()
# Add deps first
add_subdirectory(deps)
# Then everything else to avoid leaking into deps
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_EXTENSIONS OFF)
set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_DEBUG_POSTFIX _d)
function (setup_library LIBRARY_NAME IS_STATIC SOURCES)
if (IS_STATIC)
add_library(${LIBRARY_NAME} STATIC ${SOURCES})
else ()
string(TOUPPER ${LIBRARY_NAME} LIBRARY_NAME_UPPER)
add_library(${LIBRARY_NAME} SHARED ${SOURCES})
target_compile_definitions(${LIBRARY_NAME} PUBLIC ${LIBRARY_NAME_UPPER}_SHARED)
target_compile_definitions(${LIBRARY_NAME} PRIVATE ${LIBRARY_NAME_UPPER}_BUILD)
set_target_properties(${LIBRARY_NAME} PROPERTIES C_VISIBILITY_PRESET hidden)
endif ()
if (NOT MSVC)
target_link_options(${LIBRARY_NAME} PRIVATE
-Wl,--exclude-libs,ALL
-Wl,--no-whole-archive
)
endif ()
endfunction ()
if (MSVC)
# 4200: Flexible array member is a standard feature since C99
add_compile_options(/W4 /WX /wd4200)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
# MSVC does not define max_align_t
add_compile_definitions(HEY_ALIGN_TYPE=double)
else()
add_compile_options(-Wall -Wextra -pedantic -Werror)
endif()
add_library(hey INTERFACE)
target_include_directories(hey INTERFACE .)
set(MATH_LIB "")
include(CheckLibraryExists)
check_library_exists(m expf "" LIBM)
if(LIBM)
list(APPEND MATH_LIB "m")
endif()
add_subdirectory(examples)