diff --git a/code/CMakeLists.txt b/code/CMakeLists.txt index 6665ecb..3527e36 100644 --- a/code/CMakeLists.txt +++ b/code/CMakeLists.txt @@ -1,4 +1,6 @@ cmake_minimum_required(VERSION 2.6) +include(CheckCCompilerFlag) +include(CheckCXXCompilerFlag) project(jk2sp) @@ -9,23 +11,45 @@ elseif(cpu STREQUAL "x86_64") set(cpu "amd64") endif() +if(CMAKE_COMPILER_IS_GNUC OR CMAKE_C_COMPILER_ID STREQUAL "Clang") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -O2") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-strict-aliasing -fno-strict-overflow") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-unknown-pragmas") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-write-strings -Wno-missing-braces") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-switch -Wno-comment") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-variable") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-multichar") +endif() + if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - add_definitions(-pipe) - add_definitions(-Wall) - add_definitions(-g) - add_definitions(-O2) - add_definitions(-Wno-unknown-pragmas) - add_definitions(-Wno-write-strings) - add_definitions(-Wno-missing-braces) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pipe -O2") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing -fno-strict-overflow") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-unknown-pragmas") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-write-strings -Wno-missing-braces") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-switch -Wno-comment") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-variable") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-multichar") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-reorder") endif() if(CMAKE_COMPILER_IS_GNUCXX) - add_definitions(-Wno-pragmas) - add_definitions(-fpermissive) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-pragmas") endif() if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - add_definitions(-Wno-parentheses-equality) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-parentheses-equality") +endif() + +check_c_compiler_flag(-Wno-unused-but-set-variable cc_has_unused_but_set) +if (cc_has_unused_but_set) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-unused-but-set-variable") +endif() + +check_cxx_compiler_flag(-Wno-unused-but-set-variable cxx_has_unused_but_set) +if (cxx_has_unused_but_set) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-but-set-variable") endif() add_definitions( -D_M_IX86=1 ) # tested to mean little endian...