Hmm. I'll have to give that a try. Thanks
_________________________________________________________
Mike Jackson                  mike.jack...@bluequartz.net

On Wed, Dec 9, 2009 at 4:48 PM, Clinton Stimpson <clin...@elemtech.com> wrote:
> On Wednesday 09 December 2009 02:42:13 pm you wrote:
>> _________________________________________________________
>> Mike Jackson                  mike.jack...@bluequartz.net
>> BlueQuartz Software                    www.bluequartz.net
>> Principal Software Engineer                  Dayton, Ohio
>>
>> On Wed, Dec 9, 2009 at 4:33 PM, Clinton Stimpson <clin...@elemtech.com>
> wrote:
>> > On Wednesday 09 December 2009 02:23:34 pm Mike Jackson wrote:
>> >> On Wed, Dec 9, 2009 at 4:05 PM, Glenn Hughes <ghughes02...@gmail.com>
> wrote:
>> >> > Thanks Mike,
>> >> >
>> >> > I pretty much got my build process on the Mac working. The thing that
>> >> > took me awhile to understand were the different running contexts that
>> >> > bits of the CMake script are processed within. What I want is a little
>> >> > different than the standard way that things are done in the CMake way
>> >> > of handling Frameworks and bundles. I basically always want the
>> >> > Frameworks copied into the app, not just during the install phase.
>> >> >
>> >> > Here's what I'm doing:
>> >> >
>> >> > 1) In my framework CMakeLists.txt file, I have the following:
>> >> >
>> >> > IF (APPLE)
>> >> >        SET_TARGET_PROPERTIES( MyFramework PROPERTIES FRAMEWORK true)
>> >> >        SET_TARGET_PROPERTIES( MyFramework PROPERTIES
>> >> > XCODE_ATTRIBUTE_INSTALL_PATH @executable_path/../Frameworks/  )
>> >> > ENDIF (APPLE)
>> >> >
>> >> > The second "set_target_properties" line configures the framework to
>> >> > always be looked for in the application bundle in the Frameworks
>> >> > sub-folder.
>> >> >
>> >> > 2) In my top-level CMakeLists.txt file, I add setup a unified binary
>> >> > output directory (thanks Mike!):
>> >> >
>> >> > SET (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin)
>> >> > SET (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin )
>> >> > SET (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Bin )
>> >> >
>> >> > 3) Then, in my applications' CMakeLists.txt file, I have the
>> >> > following:
>> >> >
>> >> > IF (APPLE)
>> >> >        ADD_CUSTOM_COMMAND(
>> >> >                TARGET MyApp
>> >> >                POST_BUILD
>> >> >                COMMAND ${PYTHON_EXECUTABLE}
>> >> >                ARGS ${CMAKE_HOME_DIRECTORY}/CopyFramework.py
>> >> >                --binary ${PROJECT_BINARY_DIR}/Bin
>> >> >                --framework MyFramework.framework
>> >> >                --app MyApp.app
>> >> >
>> >> >     )
>> >> > ENDIF (APPLE)
>> >> >
>> >> > This calls out to my python script, which does the work of assembling
>> >> > the src and dest paths, and actually copying the Framework.
>> >> >
>> >> > The final trick is that since this is a Mac only thing, I can rely on
>> >> > an Xcode environment variable within the Python script:
>> >> >                config= os.environ["CONFIGURATION"]
>> >> >
>> >> > This allows me to assemble the complete path to the actual binary
>> >> > locations of the framework and the app.
>> >> >
>> >> > The one thing I wish was that there was a CMake variable that would
>> >> > expand to the current Config within the context of the
>> >> > ADD_CUSTOM_COMMAND... It'd be nice to not have to resort to using the
>> >> > Xcode environment variable.
>> >> >
>> >> > Thanks again
>> >> > Glenn
>> >>
>> >> Looks like you generally have a handle on things. The subtle thing
>> >> about the Xcode Environment variables is that your CMake Code is run
>> >> at "Cmake Time" which will have no idea about the Xcode variables that
>> >> are set during a "Build Time". Chicken-and-Egg sort of thing. In the
>> >> recent HDF5 Version 1.8 CMake Port/Fork I have the following code that
>> >> runs an executable as soon as it is compiled:
>> >>
>> >> SET (CFG_INIT "/${CMAKE_CFG_INTDIR}")
>> >
>> > Don't you mean "/\${CMAKE_CFG_INTDIR}", so the proper variable
>> > substitution happens later?
>> > If so, is that why you have an IF(XCODE) section?
>> >
>> > Clint
>>
>> Well I tried that and either CMake or Xcode just didn't really know
>> what to do with it.
>>
>> CMake turns the add_custom_command into a shell script. The
>> "CONFIGURATION" is an environment variable that is set by Xcode during
>> the execution of the shell script so during the actual execution the
>> proper value gets substituted and everything works. If there is a
>> better way, I am all ears..
>
> This works for me in XCode/Visual Studio/Makefiles/etc...:
>
> ADD_CUSTOM_COMMAND(
>  OUTPUT ${foo_BINARY_DIR}/allwords.h
>  COMMAND ${foo_BINARY_DIR}/CMake/${CMAKE_CFG_INTDIR}/wordlist
>  ARGS allwords.h ${COMMAND_TABLES}
>  DEPENDS ${COMMAND_TABLES}
>        ${foo_BINARY_DIR}/CMake/${CMAKE_CFG_INTDIR}/wordlist
>       )
>
> Clint
>
>
_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to