Skip to content

Commit

Permalink
Update CMakeLists.txt
Browse files Browse the repository at this point in the history
  • Loading branch information
recp committed Oct 30, 2021
1 parent e8ce20d commit a709ac6
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
cmake_minimum_required(VERSION 3.8.2)
project(ds VERSION 0.2.2 LANGUAGES C)

if(POLICY CMP0076)
cmake_policy(SET CMP0076 NEW)
endif()

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED YES)
set(DEFAULT_BUILD_TYPE "Release")

set(CMAKE_C_FLAGS_DEBUG "-g")
set(CMAKE_C_FLAGS_RELEASE "-O3")

set(DS_BUILD)
option(DS_SHARED "Shared build" ON)
option(DS_STATIC "Static build" OFF)
Expand All @@ -22,10 +29,18 @@ if(DS_USE_C99)
endif()

if(MSVC)
add_definitions(-DNDEBUG -D_WINDOWS -D_USRDLL -DDS_EXPORTS -DDS_DLL)
add_compile_options(/W3 /Ox /Gy /Oi /TC)
add_definitions(-DNDEBUG -D_WINDOWS -D_USRDLL -DDS_EXPORTS)
add_compile_options(/W3 /Ox /Gy /Oi /TC)

# Ref: https://skia.googlesource.com/third_party/sdl/+/refs/heads/master/CMakeLists.txt#225
# Make sure /RTC1 is disabled, otherwise it will use functions from the CRT
foreach(flag_var
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO)
string(REGEX REPLACE "/RTC(su|[1su])" "" ${flag_var} "${${flag_var}}")
endforeach(flag_var)
else()
add_compile_options(-Wall -Werror -O3)
add_compile_options(-Wall -Wextra -O3 -Wstrict-aliasing=2 -Wno-overlength-strings -Wmissing-declarations)
endif()

if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
Expand Down Expand Up @@ -58,6 +73,12 @@ add_library(${PROJECT_NAME}
src/sort/sort.c
)

if(DS_SHARED)
add_definitions(-DDS_EXPORTS)
else()
target_compile_definitions(${PROJECT_NAME} PUBLIC -DDS_STATIC)
endif()

set_target_properties(${PROJECT_NAME} PROPERTIES
VERSION ${PROJECT_VERSION}
SOVERSION ${PROJECT_VERSION_MAJOR})
Expand Down

0 comments on commit a709ac6

Please sign in to comment.