Hello,

I fear you're one of the first users of the XCtest feature :)

On 21/03/16 13:42, Vladimír Vondruš wrote:
Hello,

I came across this problem when trying to use XCTest macros ( 
https://cmake.org/cmake/help/latest/module/FindXCTest.html ) on iOS. When 
compiling for OSX, ctest properly executes all test cases, but when targeting 
iOS or iOS simulator, all the test cases fail similarly to the following:

     25: Test command: /Applications/Xcode.app/Contents/Developer/usr/bin/xctest 
"/Users/mosra/Code/corrade/build-ioss/src/Corrade/Utility/Test/Debug${EFFECTIVE_PLATFORM_NAME}/UtilityTypeTraitsTestRunner.xctest/../.."
     25: Environment variables:
     25:  
DYLD_FRAMEWORK_PATH=/Users/mosra/Code/corrade/build-ioss/src/Corrade/Utility/Test/Debug${EFFECTIVE_PLATFORM_NAME}/UtilityTypeTraitsTest.framework/..
     25: Test timeout computed to be: 9.99988e+06
     25: 2016-03-21 12:41:38.799 xctest[31113:31078264] The bundle “Test” 
couldn’t be loaded because its executable couldn’t be located. Try reinstalling 
the bundle.
     25/28 Test #25: UtilityTypeTraitsTest ...............***Failed    0.04 sec

As you can see, the `${EFFECTIVE_PLATFORM_NAME}` is not being expanded to 
`-iphonesimulator` and thus the file is not found. The problem is that the 
`$<TARGET_LINKER_FILE_DIR:target>` generator expression does not expand the 
variable. On the other hand, installation works without an issue, because the 
`cmake_install.cmake` scripts do additional round of variable expansion that 
(accidentally?) fixes this. The relevant part of the CMake source is here: 
https://github.com/Kitware/CMake/blob/cd569b962dbeaa7ea718021c16582cddd158df3a/Source/cmGeneratorTarget.cxx#L5063

 From the source it looks like the generator is just putting the 
"${EFFECTIVE_PLATFORM_NAME}" output and hopes that someone later expands it. 
That's the case with install scripts (so they work), but not with generator expressions. 
The `TARGET_LINKER_FILE_DIR` is not the only affected, the problem is the same for all 
`TARGET_*` generator expressions.

Currently I'm working around this by partially hardcoding the path, but that's 
far from ideal and I would like to avoid that:

     if(CMAKE_OSX_SYSROOT MATCHES "iPhoneOS")
         set(platform_name "-iphoneos")
     elseif(CMAKE_OSX_SYSROOT MATCHES "iPhoneSimulator")
         set(platform_name "-iphonesimulator")
     endif()
     set(target_linker_file_dir 
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>${platform_name}/${target}.xctest)

Is there any way to fix this directly in CMake? Also the above workaround works 
only when targeting single SDK and not when having single generated project for 
both the device and the simulator.

Could you please send me a minimal example and a command line how you invoke CMake?

Thanks,
Gregor
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to