I'm working on a project where most of it has to be compiled in C++ 98, however, I have exactly one file that needs to be compiled with C++ 11 instead.
Current example code:
set(SOURCES
file1.cpp
file2.cpp
file3.cpp
)
add_library(examplelibraryname SHARED ${SOURCES})
I want to specify that file3.cpp
needs to be compiled with CXX STANDARD 11.
I tried doing a set_target_properties(examplelibraryname PROPERTIES CXX_STANDARD 11)
on the whole library, but unfortunately one of the other files can't compile with C++ 11.
I have tried specifying just the target file by using:
set_property(SOURCE file3.cpp PROPERTY CXX_STANDARD 11)
but unfortunately I still get the errors associated with not compiling it with C++ 11 (presumably because this line is not affecting the add_library
line).
Is there any way for me to specify that just that file for the library should use C++ 11?