On Thu, Feb 18, 2010 at 05:02:38PM -0500, Benoit Thomas wrote:
> I am trying to do something like this:
> 
> function (FOO_DEBUG)
>     ...
> endfunction (FOO_DEBUG)
> 
> function (FOO_RELEASE)
>     ...
> endfunction (FOO_RELEASE)
> 
> foreach (CONFIG ${CMAKE_CONFIGURATION_TYPES})
>     FOO_${CONFIG}
> endforeach(CONFIG)
> 
> But naturally, it doesn't work :(

Check out
http://www.cmake.org/Wiki/CMake/Language_Syntax#Substitution_of_command_names.

Here's an example of how I use it in my project:

        # If this buildable needs to modify CMAKE_CXX_FLAGS*, it will
        # create a macro to handle the modifications.
        if (COMMAND ${PROJECT_NAME}_compiler_linker_flags)
            # We would like to just call
            # ${PROJECT_NAME}_compiler_linker_flags () here, but we
            # can't do it directly. This workaround accomplishes the
            # same thing. See
            # 
http://www.cmake.org/Wiki/CMake/Language_Syntax#Substitution_of_command_names.
            file (WRITE
                
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_complier_linker_flags.cmake"
                "${PROJECT_NAME}_compiler_linker_flags ()"
            )
            include 
("${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}_complier_linker_flags.cmake")
        endif ()


hth,
tyler
_______________________________________________
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