From 13a394e07fed9e805b76941e235523a0c371883f Mon Sep 17 00:00:00 2001 From: Gary Talent Date: Tue, 13 Mar 2018 20:26:12 -0500 Subject: [PATCH] Cleanup main CMakeLists.txt to better match CMake conventions --- deps/ox/CMakeLists.txt | 48 +++++++++++++++++------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) diff --git a/deps/ox/CMakeLists.txt b/deps/ox/CMakeLists.txt index de56f667..9742d7f4 100644 --- a/deps/ox/CMakeLists.txt +++ b/deps/ox/CMakeLists.txt @@ -11,52 +11,42 @@ set(OX_USE_STDLIB "ON" CACHE STRING "Build libraries that need the std lib (ON/O # can't run tests without building them if(OX_BUILD_EXEC STREQUAL "OFF" OR OX_USE_STDLIB STREQUAL "OFF") - set(OX_BUILD_EXEC "OFF") - set(OX_RUN_TESTS "OFF") + set(OX_BUILD_EXEC OFF) + set(OX_RUN_TESTS OFF) endif() set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_EXTENSIONS OFF) +if (CMAKE_BUILD_TYPE STREQUAL "Release") + add_definitions(-DNDEBUG) +else() + add_definitions(-DDEBUG) +endif() + if(OX_USE_STDLIB STREQUAL "ON") add_definitions(-DOX_USE_STDLIB) +else() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -nostdlib") endif() if(NOT MSVC) - add_definitions( - -std=c++17 - -nostdlib - -fno-exceptions - -fno-rtti - -Wall - -Wextra - -Wsign-compare - -Wunused-variable - ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wsign-compare") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wunused-variable") + if (CMAKE_BUILD_TYPE STREQUAL "Release") - add_definitions( - -Werror - -O3 - ) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3") endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - add_definitions( - -fdiagnostics-color # forces colored output when using ninja - ) + # forces colored output when using ninja + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fdiagnostics-color") endif() endif() -if (CMAKE_BUILD_TYPE STREQUAL "Release") - add_definitions( - -DNDEBUG - ) -else() - add_definitions( - -DDEBUG - ) -endif() - enable_testing() include_directories("src")