I need to compile different versions of a certain project by adding compiler switches. Usually I would do this by using add_definitions or something like
set_p
Container CMakeLists.txt
solution
Tricky solution:
Your read only CMakeList.txt
path: ${path}/ReadOnlyProject/CMakeLists.txt
Create a new CMakeList.txt
to upper to the read only library (${path}/CMakeLists.txt
):
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.0)
PROJECT (FAKE_PROJECT)
ADD_DEFINITIONS(-D_MYDEFINE=1)
ADD_SUBDIRECTORY(ReadOnlyProject)
Now use your new project (FAKE_PROJECT
) to compile. If the ReadOnlyProject
does not set compilers definitions directly, it could work.
On Visual Studio 2010:
Try to modify c:\Users\${username}\AppData\Local\Microsoft\MSBuild\v4.0\Microsoft.Cpp.Win32.user.props
to add custom compiler settings.
You should add the followings:
...
__MYDEFINE=1;%(PreprocessorDefinitions)