@@ -131,30 +131,33 @@ ELSE()
131
131
MESSAGE (status "Skipping compiler version check." )
132
132
ENDIF ()
133
133
134
- # Configure C++ and C standards
135
- IF (CMAKE_VERSION VERSION_LESS "3.1" )
136
- IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
137
- SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98" )
138
- ELSEIF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
139
- SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98" )
140
- ELSEIF (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
141
- SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++98" )
142
- ELSE ()
143
- MESSAGE (warning "C++ standard could not be set because compiler is not GNU, Clang or MSVC." )
144
- ENDIF ()
134
+ # Configure C++ standard if not externally specified (will actually be
135
+ # set after CppUnit check below). Use the variable CMAKE_CXX_STANDARD
136
+ # since it will actually be used for this purposes starting in CMake 3.1.
145
137
146
- IF (CMAKE_C_COMPILER_ID STREQUAL "GNU" )
147
- SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99" )
148
- ELSEIF (CMAKE_C_COMPILER_ID STREQUAL "Clang" )
149
- SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99" )
150
- ELSEIF (CMAKE_C_COMPILER_ID STREQUAL "MSVC" )
151
- SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11" )
152
- ELSE ()
153
- MESSAGE (warning "C standard could not be set because compiler is not GNU, Clang or MSVC." )
154
- ENDIF ()
155
- ELSE ()
156
- SET (CMAKE_C_STANDARD 90)
138
+ IF (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" )
157
139
SET (CMAKE_CXX_STANDARD 98)
140
+ ELSEIF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" )
141
+ SET (CMAKE_CXX_STANDARD 98)
142
+ ELSEIF (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC" )
143
+ SET (CMAKE_CXX_STANDARD 98)
144
+ ELSE ()
145
+ message (warning "C++ standard could not be set because compiler is not GNU, Clang or MSVC." )
146
+ ENDIF ()
147
+
148
+ IF (CMAKE_C_COMPILER_ID STREQUAL "GNU" )
149
+ SET (CMAKE_C_STANDARD 99)
150
+ ELSEIF (CMAKE_C_COMPILER_ID STREQUAL "Clang" )
151
+ SET (CMAKE_C_STANDARD 99)
152
+ ELSEIF (CMAKE_C_COMPILER_ID STREQUAL "MSVC" )
153
+ SET (CMAKE_C_STANDARD 11)
154
+ ELSE ()
155
+ message (warning "C standard could not be set because compiler is not GNU, Clang or MSVC." )
156
+ ENDIF ()
157
+
158
+ # if cmake version is < 3.1, explicitly set C standard to use.
159
+ IF (${CMAKE_VERSION} VERSION_LESS "3.1" )
160
+ SET (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c${CMAKE_C_STANDARD} " )
158
161
ENDIF ()
159
162
160
163
########################################################################
@@ -369,6 +372,19 @@ GR_REGISTER_COMPONENT("testing-support" ENABLE_TESTING
369
372
CPPUNIT_FOUND
370
373
)
371
374
375
+ # check if CppUnit version is 1.14.0 or greater; requires c++11 ...
376
+
377
+ if (CPPUNIT_FOUND AND NOT "${CPPUNIT_VERSION} " VERSION_LESS "1.14.0" )
378
+ message (WARNING "\n Warning: CppUnit version is ${CPPUNIT_VERSION} which requires C++11 for building. Trying to set CMake internally to use C++11 ..." )
379
+ SET (CMAKE_CXX_STANDARD 11)
380
+ endif ()
381
+
382
+ # if cmake version is < 3.1, explicitly set C++ standard to use.
383
+
384
+ if (${CMAKE_VERSION} VERSION_LESS "3.1" )
385
+ set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${CMAKE_CXX_STANDARD} " )
386
+ endif ()
387
+
372
388
########################################################################
373
389
# Add optional dlls specified in DLL_PATHS
374
390
########################################################################
0 commit comments