@@ -19,7 +19,7 @@ endif()
1919
2020set (DEFAULT_PROJECT_OPTIONS
2121 DEBUG_POSTFIX "d"
22- CXX_STANDARD 11
22+ CXX_STANDARD 11 # Not available before CMake 3.1; see below for manual command line argument addition
2323 LINKER_LANGUAGE "CXX"
2424 POSITION_INDEPENDENT_CODE ON
2525 CXX_VISIBILITY_PRESET "hidden"
@@ -66,6 +66,7 @@ set(DEFAULT_COMPILE_OPTIONS)
6666# MSVC compiler options
6767if ("${CMAKE_CXX_COMPILER_ID} " MATCHES "MSVC" )
6868 set (DEFAULT_COMPILE_OPTIONS ${DEFAULT_COMPILE_OPTIONS}
69+ PRIVATE
6970 /MP # -> build with multiple processes
7071 /W4 # -> warning level 4
7172 # /WX # -> treat warnings as errors
@@ -85,12 +86,19 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
8586 /GL # -> whole program optimization: enable link-time code generation (disables Zi)
8687 /GF # -> enable string pooling
8788 >
89+
90+ # No manual c++11 enable for MSVC as all supported MSVC versions for cmake-init have C++11 implicitly enabled (MSVC >=2013)
91+
92+ PUBLIC
8893 )
8994endif ()
9095
9196# GCC and Clang compiler options
9297if ("${CMAKE_CXX_COMPILER_ID} " MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID} " MATCHES "Clang" )
9398 set (DEFAULT_COMPILE_OPTIONS ${DEFAULT_COMPILE_OPTIONS}
99+ PRIVATE
100+ #-fno-exceptions # since we use stl and stl is intended to use exceptions, exceptions should not be disabled
101+
94102 -Wall
95103 -Wextra
96104 -Wunused
@@ -124,6 +132,7 @@ if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCH
124132 -pthread
125133 >
126134
135+ # Required for CMake < 3.1; should be removed if minimum required CMake version is raised.
127136 $<$<VERSION_LESS :${CMAKE_VERSION} ,3.1>:
128137 -std=c++11
129138 >
@@ -140,6 +149,7 @@ set(DEFAULT_LINKER_OPTIONS)
140149# Use pthreads on mingw and linux
141150if ("${CMAKE_CXX_COMPILER_ID} " MATCHES "GNU" OR "${CMAKE_SYSTEM_NAME} " MATCHES "Linux" )
142151 set (DEFAULT_LINKER_OPTIONS
152+ PUBLIC
143153 -pthread
144154 )
145155endif ()
0 commit comments