@@ -79,20 +79,43 @@ if( CINDER_MSW AND MSVC )
7979 endif ()
8080endif ()
8181
82- target_compile_features ( cinder PUBLIC cxx_std_17 )
82+ # Determine C++ standard for Cinder (default 17, allow user override)
83+ if ( CMAKE_CXX_STANDARD )
84+ set ( CINDER_CXX_STANDARD ${CMAKE_CXX_STANDARD} )
85+ else ()
86+ set ( CINDER_CXX_STANDARD 17 )
87+ endif ()
88+
89+ # Validate minimum
90+ if ( CINDER_CXX_STANDARD LESS 17 )
91+ message ( FATAL_ERROR "Cinder requires C++17 or later. CMAKE_CXX_STANDARD is set to ${CINDER_CXX_STANDARD} " )
92+ endif ()
93+
94+ # Set C++ standard for cinder target
95+ target_compile_features ( cinder PUBLIC cxx_std_${CINDER_CXX_STANDARD} )
96+
97+ # Determine CXX_EXTENSIONS: default OFF (prevents "namespace linux" issue)
98+ # Only enable if user explicitly sets CMAKE_CXX_EXTENSIONS=ON
99+ if ( DEFINED CMAKE_CXX_EXTENSIONS )
100+ set ( CINDER_CXX_EXTENSIONS ${CMAKE_CXX_EXTENSIONS} )
101+ else ()
102+ set ( CINDER_CXX_EXTENSIONS OFF )
103+ endif ()
104+
83105set_target_properties ( cinder PROPERTIES
84- CXX_STANDARD 17
106+ CXX_STANDARD ${CINDER_CXX_STANDARD}
85107 CXX_STANDARD_REQUIRED ON
86- CXX_EXTENSIONS OFF
108+ CXX_EXTENSIONS ${CINDER_CXX_EXTENSIONS}
87109)
88110
89111# This file will contain all dependencies, includes, definition, compiler flags and so on..
90112export ( TARGETS cinder FILE ${PROJECT_BINARY_DIR} /${CINDER_LIB_DIRECTORY}/cinderTargets.cmake )
91113
92114# And this command will generate a file on the ${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}
93115# that applications have to pull in order to link successfully with Cinder and its dependencies.
94- # This specific cinderConfig.cmake file will just hold a path to the above mention
116+ # This specific cinderConfig.cmake file will just hold a path to the above mention
95117# cinderTargets.cmake file which holds the actual info.
118+ # CINDER_CXX_STANDARD and CINDER_CXX_EXTENSIONS will be substituted into the template
96119configure_file ( ${CMAKE_CURRENT_LIST_DIR} /modules/cinderConfig.buildtree.cmake.in
97120 "${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} /cinderConfig.cmake"
98121)
0 commit comments