[CMake] Fw: Re: Problems generating Xcode projects

Kai Sterker kai.sterker at gmail.com
Tue Jul 15 09:42:54 EDT 2008


On Tue, Jul 15, 2008 at 3:33 PM, Samuel Crow

>> I've had the same problems.

I used to have problems with incorrect quoting in connection with
ADD_DEFINITIONS in CMake prior to 2.6. If your CMakeLists.txt files
had been written to work around this issue in 2.4, they might be
broken with 2.6.

I put the following in my toplevel CMakeLists.txt to work around this
specific issue in both CMake 2.4 and 2.6

 # -- for CMake 2.6.x
if(COMMAND cmake_policy)
# -- use automatic escaping in add_definitions
    cmake_policy(SET CMP0005 NEW)
    set(ESCAPE "")
else(COMMAND cmake_policy)

# -- pre 2.6 needs escaping in add_definitions
if(CMAKE_GENERATOR MATCHES ".*Makefiles")
    set(ESCAPE "\\\"")
else(CMAKE_GENERATOR MATCHES ".*Makefiles")
    set(ESCAPE "\\\\\"")
endif(CMAKE_GENERATOR MATCHES ".*Makefiles")

endif(COMMAND cmake_policy)

Then, an ADD_DEFINITIONS that needs quoting looks like

ADD_DEFINITIONS (-DVERSION="${ESCAPE}0.4.0${ESCAPE}")

Kai


More information about the CMake mailing list