From 6d8e2cc92d791f6c9d0b476a7cc685e7581b26aa Mon Sep 17 00:00:00 2001 From: altf_four <56314286+realaltffour@users.noreply.github.com> Date: Sun, 26 Apr 2020 19:42:23 +0300 Subject: [PATCH] Add flags required for cmake. (#138) - Add flags for clang - Add flags for msvc - Use modern cmake in compiler flags handling. - Globalize compiler options for library and tests - Address issue with cmake output binary being bigger than make's. (Now cmake is smaller ~176 (confirmed on dynamic library on Linux)). --- CMakeLists.txt | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fcb53ba..1b90e59 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,14 +20,16 @@ if(CGLM_USE_C99) set(C_STANDARD 99) endif() -if("${CMAKE_C_COMPILER_ID}" STREQUAL "MSVC") - list(APPEND LDFLAGS "/W4") -elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") - set(C_EXTENSIONS YES) - list(APPEND LDFLAGS "-Wall" "-Wpedantic" "-Wstrict-aliasing=2") - list(APPEND LDFLAGS "-Werror=strict-prototypes" "-fstrict-aliasing" "-O3") -elseif("${CMAKE_C_COMPILER_ID}" STREQUAL "CLANG") - list(APPEND LDFLAGS "-Wall" "-Weverything" "-Wpedantic") +if(MSVC) + add_definitions(-DNDEBUG -D_WINDOWS -D_USRDLL -DCGLM_EXPORTS -DCGLM_DLL) + add_compile_options("/W3" "/Ox" "/Gy" "/Oi" "/TC" "/analyze") +else() + add_compile_options("-Wall" "-Werror" "-O3") + if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + add_compile_options("-stdlib=libc++" "-Weverything") + else() + add_compile_options("-Werror=strict-prototypes" "-fstrict-aliasing") + endif() endif() set(HEADERS @@ -160,10 +162,6 @@ target_include_directories(cglm PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ) -if(LDFLAGS) - target_compile_options(cglm PRIVATE ${LDFLAGS}) -endif() - install( TARGETS cglm EXPORT cglm