# This file demonstrates a bug in CMake 2.6.0 with Xcode generator. # The following TRY_RUN program will compile with Makefiles but # not with Xcode 3.0. It seems to be triggered by the use of # double quote characters in the COMPILE_DEFINITIONS. # # Author: Matt Leotta (mleotta@lems.brown.edu) # Date: July 9, 2008 # Platform: MacBook Pro (Intel) # OS: Mac OS X 10.5.4 (Leopard) # Xcode version 3.0 # CMake version 2.6.0 # # ======================== Xcode Error message ================================= # Change Dir: /projects/test/my bin/CMakeFiles/CMakeTmp # # Run Build Command:/Applications/CMake\ 2.6-0.app/Contents/bin/cmakexbuild -project # CMAKE_TRY_COMPILE.xcodeproj build -target cmTryCompileExec -configuration Debug # 2008-07-09 08:32:20.045 xcodebuild[4650:613] CFPropertyListCreateFromXMLData(): # Old-style plist parser: missing semicolon in dictionary. # 2008-07-09 08:32:20.046 xcodebuild[4650:613] XML parser error: # Unexpected character / at line 1 # Old-style plist parser error: # Missing ';' on line 168 # xcodebuild: Error: couldn't load project # /projects/test/my bin/CMakeFiles/CMakeTmp/CMAKE_TRY_COMPILE.xcodeproj # ============================================================================== PROJECT(my_test) CMAKE_MINIMUM_REQUIRED(VERSION 2.4.5) # Write a simple test program with an include file WRITE_FILE( ${CMAKE_BINARY_DIR}/CMakeTmp/my_include.h "#define TEST_VALUE 0\n") WRITE_FILE( ${CMAKE_BINARY_DIR}/my_test.cxx "#include \"my_include.h\"\nint main() { return TEST_VALUE; }") SET(INC_STRING "-I \"${CMAKE_BINARY_DIR}/CMakeTmp\"") # Removing the quotes fixes the Xcode 3 bug, but this # will fail if ${CMAKE_BINARY_DIR} contains an spaces # SET(INC_STRING "-I ${CMAKE_BINARY_DIR}/CMakeTmp") TRY_RUN(my_test my_test_COMPILED ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/my_test.cxx CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${INC_STRING} OUTPUT_VARIABLE OUTPUT) # Display the results of the test and write compilation errors to a log IF(NOT my_test_COMPILED) MESSAGE("Performing Try-Run - Test Compilation Failed") WRITE_FILE(${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Performing Try-Run my_test failed to compile with the following output:\n" "${OUTPUT}\n" APPEND) ELSE(NOT my_test_COMPILED) IF(my_test) MESSAGE("The test compiled but failed at run time") ELSE(my_test) MESSAGE("The test compiled and passed") ENDIF(my_test) ENDIF(NOT my_test_COMPILED)