Re: [CMake] EFFECTIVE_PLATFORM_NAME not expanded in TARGET_* generator expressions on iOS

2016-04-07 Thread Vladimír Vondruš
Hello,

sorry for the delayed reply. The root of the problem is actually not the XCtest 
feature, but generator expressions. The minimal repro case is just the 
following CMakeLists.txt file:

cmake_minimum_required(VERSION 3.5)

project(IosTarget C)

file(GENERATE
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/location.c
CONTENT "#define LOCATION \"$\""
CONDITION $)

add_library(lib STATIC ${CMAKE_CURRENT_BINARY_DIR}/location.c)

Create build directory and invoke CMake like this:

cmake .. 
-DCMAKE_OSX_SYSROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk
 -DCMAKE_OSX_ARCHITECTURES=armv7 -DCMAKE_C_COMPILER_WORKS=ON -G Xcode

(I had to put the CMAKE_C_COMPILER_WORKS there because of 
https://cmake.org/Bug/view.php?id=15329 -- passing the CMAKE_MACOSX_BUNDLE and 
CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED on command-line somehow didn't work 
and I didn't want to inflate the repro case with a toolchain file. By the way, 
why CMake can't set those properties implicitly for the compiler tests?)

Then, in the build directory a `location.c` file appears with contents similar 
to this:

#define LOCATION 
"/path/to/the/project/build/Debug${EFFECTIVE_PLATFORM_NAME}/liblib.a"

The expected value is however this:

   #define LOCATION "/path/to/the/project/build/Debug-iphoneos/liblib.a"

Which corresponds to the location of the generated library if you run `cmake 
--build .`

Hope the repro case is clear enough.

Regards
mosra

__
> Od: Gregor Jasny 
> Komu: "Vladimír Vondruš" , 
> Datum: 30.03.2016 14:15
> Předmět: Re: [CMake] EFFECTIVE_PLATFORM_NAME not expanded in TARGET_* 
> generator expressions on iOS
>
>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 ...***Failed0.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 
>> `$` 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}/$${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:


Re: [CMake] EFFECTIVE_PLATFORM_NAME not expanded in TARGET_* generator expressions on iOS

2016-03-30 Thread Gregor Jasny via CMake

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 ...***Failed0.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 
`$` 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}/$${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

Re: [CMake] EFFECTIVE_PLATFORM_NAME not expanded in TARGET_* generator expressions on iOS

2016-03-29 Thread Ruslan Baratov via CMake
The note about CMAKE_IOS_INSTALL_COMBINED is related to value of 
CMAKE_OSX_SYSROOT. `${EFFECTIVE_PLATFORM_NAME}` as far as I understand 
used on build step too, it's not only installation 
(`cmTarget::ComputeOutputDir`). As alternative you can try to hardcode 
`LIBRARY_OUTPUT_DIRECTORY` so both simulator and device will have same 
predictable location. I don't know about CMake internals in such depth 
to answer question about generator expression.


Ruslo

On 29-Mar-16 22:51, Vladimír Vondruš wrote:

Hm... this is unfortunate. Would it be possible to keep the 
${EFFECTIVE_PLATFORM_NAME} in place for the install step but return it 
substituted when one asks explicitly using generator expression? From what I 
understood in the docs, the CMAKE_IOS_INSTALL_COMBINED is doing something 
additional during installation step and does not affect generator step -- so I 
think a behavior specific for installation and CMAKE_IOS_INSTALL_COMBINED could 
be separated from direct use of generator expressions. Or am I completely out 
of touch?

Thank you
mosra

__

Od: Ruslan Baratov 
Komu: "Vladimír Vondruš" 
Datum: 29.03.2016 15:20
Předmět: Re: [CMake] EFFECTIVE_PLATFORM_NAME not expanded in TARGET_* generator 
expressions on iOS

CC: cmake@cmake.org
On 29-Mar-16 16:14, Vladimír Vondruš wrote:

I saw that commit, yes. Since there is no additional round of variable expansion, wouldn't it 
be better to expand the ${EFFECTIVE_PLATFORM_NAME} to at least something fixed (based on the 
value of CMAKE_OSX_SYSROOT), instead of making the generator expression unusable in all cases? 
It seems reasonable to me that if I set CMAKE_OSX_SYSROOT to "iPhoneSimulator", the 
output of $ would be something like

  /path/to/my/build/dir/Debug-iphonesimulator/something.framework

instead of:

  /path/to/my/build/dir/Debug${EFFECTIVE_PLATFORM_NAME}/something.framework

Because the latter is unusable, with the former I have at least the ability to 
use it with a single fixed SDK.

Thanks
mosra

As far as I know you have to set CMAKE_OSX_SYSROOT to "iphoneos" so
Xcode project will contain both simulator and device configuration.
Without this change such feature like CMAKE_IOS_INSTALL_COMBINED will
not work. In other words substituting `${EFFECTIVE_PLATFORM_NAME}` may
fit your needs but will broke CMAKE_IOS_INSTALL_COMBINED for everybody
(at least if this behaviour will be unconditional).

Ruslo


__

Od: Ruslan Baratov 
Komu: "Vladimír Vondruš" 
Datum: 21.03.2016 14:56
Předmět: Re: [CMake] EFFECTIVE_PLATFORM_NAME not expanded in TARGET_* generator 
expressions on iOS

CC: cmake@cmake.org
On 21-Mar-16 19: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 ...***Failed0.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 
`$` 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 

Re: [CMake] EFFECTIVE_PLATFORM_NAME not expanded in TARGET_* generator expressions on iOS

2016-03-29 Thread Vladimír Vondruš
Hm... this is unfortunate. Would it be possible to keep the 
${EFFECTIVE_PLATFORM_NAME} in place for the install step but return it 
substituted when one asks explicitly using generator expression? From what I 
understood in the docs, the CMAKE_IOS_INSTALL_COMBINED is doing something 
additional during installation step and does not affect generator step -- so I 
think a behavior specific for installation and CMAKE_IOS_INSTALL_COMBINED could 
be separated from direct use of generator expressions. Or am I completely out 
of touch?

Thank you
mosra

__
> Od: Ruslan Baratov 
> Komu: "Vladimír Vondruš" 
> Datum: 29.03.2016 15:20
> Předmět: Re: [CMake] EFFECTIVE_PLATFORM_NAME not expanded in TARGET_* 
> generator expressions on iOS
>
> CC: cmake@cmake.org
>On 29-Mar-16 16:14, Vladimír Vondruš wrote:
>> I saw that commit, yes. Since there is no additional round of variable 
>> expansion, wouldn't it be better to expand the ${EFFECTIVE_PLATFORM_NAME} to 
>> at least something fixed (based on the value of CMAKE_OSX_SYSROOT), instead 
>> of making the generator expression unusable in all cases? It seems 
>> reasonable to me that if I set CMAKE_OSX_SYSROOT to "iPhoneSimulator", the 
>> output of $ would be something like
>>
>>  /path/to/my/build/dir/Debug-iphonesimulator/something.framework
>>
>> instead of:
>>
>>  
>> /path/to/my/build/dir/Debug${EFFECTIVE_PLATFORM_NAME}/something.framework
>>
>> Because the latter is unusable, with the former I have at least the ability 
>> to use it with a single fixed SDK.
>>
>> Thanks
>> mosra
>As far as I know you have to set CMAKE_OSX_SYSROOT to "iphoneos" so 
>Xcode project will contain both simulator and device configuration. 
>Without this change such feature like CMAKE_IOS_INSTALL_COMBINED will 
>not work. In other words substituting `${EFFECTIVE_PLATFORM_NAME}` may 
>fit your needs but will broke CMAKE_IOS_INSTALL_COMBINED for everybody 
>(at least if this behaviour will be unconditional).
>
>Ruslo
>
>>
>> __
>>> Od: Ruslan Baratov 
>>> Komu: "Vladimír Vondruš" 
>>> Datum: 21.03.2016 14:56
>>> Předmět: Re: [CMake] EFFECTIVE_PLATFORM_NAME not expanded in TARGET_* 
>>> generator expressions on iOS
>>>
>>> CC: cmake@cmake.org
>>> On 21-Mar-16 19: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 
 `$` 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 
 

Re: [CMake] EFFECTIVE_PLATFORM_NAME not expanded in TARGET_* generator expressions on iOS

2016-03-29 Thread Ruslan Baratov via CMake

On 29-Mar-16 16:14, Vladimír Vondruš wrote:

I saw that commit, yes. Since there is no additional round of variable expansion, wouldn't it 
be better to expand the ${EFFECTIVE_PLATFORM_NAME} to at least something fixed (based on the 
value of CMAKE_OSX_SYSROOT), instead of making the generator expression unusable in all cases? 
It seems reasonable to me that if I set CMAKE_OSX_SYSROOT to "iPhoneSimulator", the 
output of $ would be something like

 /path/to/my/build/dir/Debug-iphonesimulator/something.framework

instead of:

 /path/to/my/build/dir/Debug${EFFECTIVE_PLATFORM_NAME}/something.framework

Because the latter is unusable, with the former I have at least the ability to 
use it with a single fixed SDK.

Thanks
mosra
As far as I know you have to set CMAKE_OSX_SYSROOT to "iphoneos" so 
Xcode project will contain both simulator and device configuration. 
Without this change such feature like CMAKE_IOS_INSTALL_COMBINED will 
not work. In other words substituting `${EFFECTIVE_PLATFORM_NAME}` may 
fit your needs but will broke CMAKE_IOS_INSTALL_COMBINED for everybody 
(at least if this behaviour will be unconditional).


Ruslo



__

Od: Ruslan Baratov 
Komu: "Vladimír Vondruš" 
Datum: 21.03.2016 14:56
Předmět: Re: [CMake] EFFECTIVE_PLATFORM_NAME not expanded in TARGET_* generator 
expressions on iOS

CC: cmake@cmake.org
On 21-Mar-16 19: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 ...***Failed0.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 
`$` 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}/$${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.

Thank you a lot for your help.

mosra

I doubt I can help with the problem but just for your information:
* it wasn't fixed "accidentally", it was a fix for #12506:
https://github.com/Kitware/CMake/commit/48fe617e667d2e6b1e471cfb56346de51f984ba5
* there is no "additional round" of variable expansion,
EFFECTIVE_PLATFORM_NAME initialized from Xcode's environment variable
EFFECTIVE_PLATFORM_NAME on installation

As far as I understand the main general problem with iOS
device/simulator support is that CMake doesn't have multi-toolchain
feature from the box. So for now all this stuff worked by generating
some "universal" code that do work for both SDKs. The real SDK can be
triggered by additional explicit option, i.e.:
* cmake --build _builds -- -sdk iphoneos # trigger iphoneos SDK
* cmake --build _builds -- -sdk iphonesimulator # trigger
iphonesimulator SDK

Ruslo



--

Powered by www.kitware.com

Please keep messages on-topic and 

Re: [CMake] EFFECTIVE_PLATFORM_NAME not expanded in TARGET_* generator expressions on iOS

2016-03-29 Thread Vladimír Vondruš
I saw that commit, yes. Since there is no additional round of variable 
expansion, wouldn't it be better to expand the ${EFFECTIVE_PLATFORM_NAME} to at 
least something fixed (based on the value of CMAKE_OSX_SYSROOT), instead of 
making the generator expression unusable in all cases? It seems reasonable to 
me that if I set CMAKE_OSX_SYSROOT to "iPhoneSimulator", the output of 
$ would be something like

/path/to/my/build/dir/Debug-iphonesimulator/something.framework

instead of:

/path/to/my/build/dir/Debug${EFFECTIVE_PLATFORM_NAME}/something.framework

Because the latter is unusable, with the former I have at least the ability to 
use it with a single fixed SDK.

Thanks
mosra

__
> Od: Ruslan Baratov 
> Komu: "Vladimír Vondruš" 
> Datum: 21.03.2016 14:56
> Předmět: Re: [CMake] EFFECTIVE_PLATFORM_NAME not expanded in TARGET_* 
> generator expressions on iOS
>
> CC: cmake@cmake.org
>On 21-Mar-16 19: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 ...***Failed0.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 
>> `$` 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}/$${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.
>>
>> Thank you a lot for your help.
>>
>> mosra
>I doubt I can help with the problem but just for your information:
>* it wasn't fixed "accidentally", it was a fix for #12506: 
>https://github.com/Kitware/CMake/commit/48fe617e667d2e6b1e471cfb56346de51f984ba5
>* there is no "additional round" of variable expansion, 
>EFFECTIVE_PLATFORM_NAME initialized from Xcode's environment variable 
>EFFECTIVE_PLATFORM_NAME on installation
>
>As far as I understand the main general problem with iOS 
>device/simulator support is that CMake doesn't have multi-toolchain 
>feature from the box. So for now all this stuff worked by generating 
>some "universal" code that do work for both SDKs. The real SDK can be 
>triggered by additional explicit option, i.e.:
>* cmake --build _builds -- -sdk iphoneos # trigger iphoneos SDK
>* cmake --build _builds -- -sdk iphonesimulator # trigger 
>iphonesimulator SDK
>
>Ruslo
>
-- 

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: 

Re: [CMake] EFFECTIVE_PLATFORM_NAME not expanded in TARGET_* generator expressions on iOS

2016-03-21 Thread Ruslan Baratov via CMake

On 21-Mar-16 19: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 ...***Failed0.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 
`$` 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}/$${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.

Thank you a lot for your help.

mosra

I doubt I can help with the problem but just for your information:
* it wasn't fixed "accidentally", it was a fix for #12506: 
https://github.com/Kitware/CMake/commit/48fe617e667d2e6b1e471cfb56346de51f984ba5
* there is no "additional round" of variable expansion, 
EFFECTIVE_PLATFORM_NAME initialized from Xcode's environment variable 
EFFECTIVE_PLATFORM_NAME on installation


As far as I understand the main general problem with iOS 
device/simulator support is that CMake doesn't have multi-toolchain 
feature from the box. So for now all this stuff worked by generating 
some "universal" code that do work for both SDKs. The real SDK can be 
triggered by additional explicit option, i.e.:

* cmake --build _builds -- -sdk iphoneos # trigger iphoneos SDK
* cmake --build _builds -- -sdk iphonesimulator # trigger 
iphonesimulator SDK


Ruslo
--

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

[CMake] EFFECTIVE_PLATFORM_NAME not expanded in TARGET_* generator expressions on iOS

2016-03-21 Thread Vladimír Vondruš
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 ...***Failed0.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 
`$` 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}/$${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.

Thank you a lot for your help.

mosra
-- 

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