Skip to content

Commit

Permalink
fix(build): fix compile and link flags
Browse files Browse the repository at this point in the history
  • Loading branch information
lmichaelis committed Dec 26, 2023
1 parent 1af0df3 commit 6e26321
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
cmake_minimum_required(VERSION 3.10)
project(ZenKitCAPI LANGUAGES CXX C VERSION 1.3.0)

include(support/BuildSupport.cmake)

set(CMAKE_CXX_STANDARD 17)

# Required for dependencies to compile properly.
Expand Down Expand Up @@ -68,6 +66,7 @@ list(APPEND _ZKC_SOURCES
src/World.cc
)

include(support/BuildSupport.cmake)
bs_select_cflags(${ZKC_ENABLE_ASAN} _ZKC_COMPILE_FLAGS _ZKC_LINK_FLAGS)

add_library(zenkitcapi SHARED)
Expand All @@ -82,3 +81,6 @@ set_target_properties(zenkitcapi PROPERTIES CXX_VISIBILITY_PRESET hidden VISIBIL

install(TARGETS zenkitcapi ARCHIVE LIBRARY RUNTIME)
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/zenkitcapi" TYPE INCLUDE)

add_executable(test test.c)
target_link_libraries(test PRIVATE zenkitcapi)
4 changes: 3 additions & 1 deletion support/BuildSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ endfunction()
## COMPILE(list): A list containing the compiler flags
## LINK(list): A list containing the linker flags
function(bs_internal_select_cflags_gcc SANITIZERS COMPILE LINK)
list(APPEND _INTERNAL_FLAGS "-Wall" "-Wextra" "-Werror" "-Wconversion" "-Wshadow" "-Wpedantic" "-fPIC")
list(APPEND _INTERNAL_FLAGS "-Wall" "-Wextra" "-Werror" "-Wconversion" "-Wshadow" "-Wpedantic" "-fPIC" "-Wno-deprecated-declarations")

if (CMAKE_BUILD_TYPE MATCHES "^Debug" AND ${SANITIZERS} AND NOT WIN32)
list(APPEND _INTERNAL_FLAGS "-fsanitize=address" "-fsanitize=undefined" "-fsanitize=leak")
Expand All @@ -73,6 +73,8 @@ endfunction()
## LINK(list): A list containing the linker flags
function(bs_internal_select_cflags_clang SANITIZERS COMPILE LINK)
bs_internal_select_cflags_gcc(${SANITIZERS} _INTERNAL_COMPILE_FLAGS _INTERNAL_LINK_FLAGS)
list(APPEND _INTERNAL_COMPILE_FLAGS "-Wno-return-type-c-linkage")
list(APPEND _INTERNAL_LINK_FLAGS "-Wno-return-type-c-linkage")

if (CMAKE_BUILD_TYPE MATCHES "^Debug")
list(APPEND _INTERNAL_COMPILE_FLAGS "-fstandalone-debug")
Expand Down

0 comments on commit 6e26321

Please sign in to comment.