11cmake_minimum_required (VERSION 3.13)
22project (wsserver C)
3+ enable_language (ASM)
34
45# Set a default build type if not specified (for single-config generators)
56if (NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES )
67 set (CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build." FORCE)
78endif ()
89
9- # Collect all .c files from the src directory and its subdirectories
10- file (GLOB_RECURSE SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR} /src/*.c" )
10+ if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
11+ # Collect all .c files from the src directory and its subdirectories
12+ file (GLOB_RECURSE SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR} /src/*.c" )
13+ else ()
14+ # Collect all .c files from the src directory and its subdirectories
15+ file (GLOB_RECURSE SRC_FILES "${CMAKE_CURRENT_SOURCE_DIR} /src/*.c" )
16+ # Collect all assembly files (*.S) from the src directory and its subdirectories
17+ file (GLOB_RECURSE ASM_FILES "${CMAKE_CURRENT_SOURCE_DIR} /src/*.S" )
18+ endif ()
1119
12- # Create the static library target
13- add_library (wsserver STATIC ${SRC_FILES} )
20+ # Create the static library target including C and assembly files
21+ add_library (wsserver STATIC ${SRC_FILES} ${ASM_FILES} )
22+ add_library (wsserver_shared SHARED ${SRC_FILES} ${ASM_FILES} )
1423
1524# Set the output directory for the static library to the "lib" folder in the build directory
1625set_target_properties (wsserver PROPERTIES
@@ -28,17 +37,28 @@ else()
2837 set (DEBUG_COMPILE_OPTIONS "-O0" "-static-libasan" "-g" )
2938endif ()
3039
31- # Add compile options and definitions for each build type using generator expressions
32- target_compile_options (wsserver PRIVATE
33- $<$<CONFIG:Debug>:${DEBUG_COMPILE_OPTIONS} >
34- $<$<CONFIG:Release>:-O3>
35- $<$<CONFIG:Release>:-fno-lto>
36- $<$<CONFIG:Release>:-mtune=native>
37- $<$<CONFIG:Release>:-ffast-math>
38- $<$<CONFIG:Release>:-fno-math-errno>
39- $<$<CONFIG:Release>:-falign-functions>
40- $<$<CONFIG:Release>:-flto=auto>
41- )
40+ if (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" )
41+ # Add compile options and definitions for each build type using generator expressions
42+ target_compile_options (wsserver PRIVATE
43+ $<$<CONFIG:Debug>:${DEBUG_COMPILE_OPTIONS} >
44+ $<$<CONFIG:Release>:-O3>
45+ $<$<CONFIG:Release>:-mtune=native>
46+ $<$<CONFIG:Release>:-ffast-math>
47+ $<$<CONFIG:Release>:-fno-math-errno>
48+ $<$<CONFIG:Release>:-falign-functions>
49+ )
50+ else ()
51+ # Add compile options and definitions for each build type using generator expressions
52+ target_compile_options (wsserver PRIVATE
53+ $<$<CONFIG:Debug>:${DEBUG_COMPILE_OPTIONS} >
54+ $<$<CONFIG:Release>:-O3>
55+ $<$<CONFIG:Release>:-mtune=native>
56+ $<$<CONFIG:Release>:-ffast-math>
57+ $<$<CONFIG:Release>:-fno-math-errno>
58+ $<$<CONFIG:Release>:-falign-functions>
59+ $<$<CONFIG:Release>:-flto=auto>
60+ )
61+ endif ()
4262
4363target_compile_definitions (wsserver PRIVATE
4464 $<$<CONFIG:Debug>:LOG_LEVEL_DEBUG>
0 commit comments