CPack OS X bundle : generator expression for CPACK_BUNDLE_STARTUP_COMMAND

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

CPack OS X bundle : generator expression for CPACK_BUNDLE_STARTUP_COMMAND

Nicholas Yue
I am using CMake 3.10

I can't seems to find a way to tell the OS X bundle where to find the compiled binary.

I get the following errors:

Run CPack packaging tool...
CPack: Create package using Bundle
CPack: Install projects
CPack: - Run preinstall target for: OSXBundle
CPack: - Install project: OSXBundle
CPack: Create package
CPack Error: Error copying $<TARGET_FILE:myapp> to /Users/nicholas/projects/OSX_BundleRPath/build/_CPack_Packages/Darwin/Bundle/OSXBundle-0.1.1-Darwin/MyApp.app/Contents/MacOS/MyApp
CPack Error: Error copying startup command.  Check the value of CPACK_BUNDLE_STARTUP_COMMAND.
CPack Error: Problem compressing the directory
CPack Error: Error when generating package: OSXBundle
make: *** [package] Error 1


I have the following CMakeLists.txt:

CMAKE_MINIMUM_REQUIRED(VERSION 3.8)

PROJECT (OSXBundle)

FIND_PACKAGE (Boost REQUIRED)

ADD_EXECUTABLE (myapp
  src/main.cpp
  )

INSTALL ( TARGETS
  myapp
  DESTINATION
  ./bin
  )

IF (APPLE)
  # GET_TARGET_PROPERTY ( APP_LOCATION myapp LOCATION )
  SET ( APP_LOCATION "$<TARGET_FILE:myapp>" )
  
  SET ( CPACK_BUNDLE_NAME "MyApp" )
  
  SET ( CPACK_GENERATOR "Bundle" )
  SET ( CPACK_BUNDLE_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/resources/Info.plist )
  SET ( CPACK_BUNDLE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/resources/MyApp.icns )
  SET ( CPACK_PACKAGE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/resources/MyApp.icns )
  SET ( CPACK_BUNDLE_STARTUP_COMMAND ${APP_LOCATION} )
ENDIF ()

INCLUDE ( CPack )


--

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 | Threaded
Open this post in threaded view
|

Re: CPack OS X bundle : generator expression for CPACK_BUNDLE_STARTUP_COMMAND

Oleksii Vilchanskyi
Hi,

`set()` is evaluated at configuration time and as of CMake 3.10 does not
accept genexps. You can refer to this diagram for better understanding
of the general CMake pipeline:
<https://cgold.readthedocs.io/en/latest/_images/cmake-environment.png>

Therefore,

>   SET ( APP_LOCATION "$<TARGET_FILE:myapp>" )
>   SET ( CPACK_BUNDLE_STARTUP_COMMAND ${APP_LOCATION} )

is interpreted exactly how it's written:

> CPack Error: Error copying $<TARGET_FILE:myapp> to...

Due to this limitation your [probably] sole option to introduce genxps
in CPack config would be to use `file(GENERATE)`. Otherwise, use
single-configuration generators and you won't have
configuration-dependent paths.

On 29.11.2017 01:50, Nicholas Yue wrote:

> I am using CMake 3.10
>
> I can't seems to find a way to tell the OS X bundle where to find the
> compiled binary.
>
> I get the following errors:
>
> Run CPack packaging tool...
> CPack: Create package using Bundle
> CPack: Install projects
> CPack: - Run preinstall target for: OSXBundle
> CPack: - Install project: OSXBundle
> CPack: Create package
> CPack Error: Error copying $<TARGET_FILE:myapp> to
> /Users/nicholas/projects/OSX_BundleRPath/build/_CPack_Packages/Darwin/Bundle/OSXBundle-0.1.1-Darwin/MyApp.app/Contents/MacOS/MyApp
> CPack Error: Error copying startup command.  Check the value of
> CPACK_BUNDLE_STARTUP_COMMAND.
> CPack Error: Problem compressing the directory
> CPack Error: Error when generating package: OSXBundle
> make: *** [package] Error 1
>
>
> I have the following CMakeLists.txt:
>
> CMAKE_MINIMUM_REQUIRED(VERSION 3.8)
>
> PROJECT (OSXBundle)
>
> FIND_PACKAGE (Boost REQUIRED)
>
> ADD_EXECUTABLE (myapp
>   src/main.cpp
>   )
>
> INSTALL ( TARGETS
>   myapp
>   DESTINATION
>   ./bin
>   )
>
> IF (APPLE)
>   # GET_TARGET_PROPERTY ( APP_LOCATION myapp LOCATION )
>   SET ( APP_LOCATION "$<TARGET_FILE:myapp>" )
>   
>   SET ( CPACK_BUNDLE_NAME "MyApp" )
>   
>   SET ( CPACK_GENERATOR "Bundle" )
>   SET ( CPACK_BUNDLE_PLIST
> ${CMAKE_CURRENT_SOURCE_DIR}/resources/Info.plist )
>   SET ( CPACK_BUNDLE_ICON ${CMAKE_CURRENT_SOURCE_DIR}/resources/MyApp.icns )
>   SET ( CPACK_PACKAGE_ICON
> ${CMAKE_CURRENT_SOURCE_DIR}/resources/MyApp.icns )
>   SET ( CPACK_BUNDLE_STARTUP_COMMAND ${APP_LOCATION} )
> ENDIF ()
>
> INCLUDE ( CPack )
>
>
>
--
Regards,
Oleksii Vilchanskyi
PGP:0x8D3A0E046BDE941F2A53867CE3FD952D48C0B338

***
All the world's a pipeline,
And all the men and women merely instructions.


--

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

signature.asc (849 bytes) Download Attachment