[CMake] calling c-compiler by hand

Michael Hertling mhertling at online.de
Mon Jul 12 12:04:22 EDT 2010


On 07/12/2010 04:14 PM, Jochen Wilhelmy wrote:
> Hi!
> 
> I'd like to call the c-compiler by hand as pre-link step to compile in 
> the current svn version.
> 
> on windows i first separate the arguments
> 
> separate_arguments(CFLAGS WINDOWS_COMMAND "${CMAKE_CXX_FLAGS} 
> ${CMAKE_CXX_FLAGS_DEBUG} /c")
> 
> and then I do
> 
> add_custom_command(TARGET MyProject PRE_LINK
>      COMMAND ${CMAKE_CXX_COMPILER} ${CFLAGS} 
> "${CMAKE_CURRENT_SOURCE_DIR}/VersionInfo.cpp"
>      VERBATIM
> )

Why don't you simply mention ${CMAKE_CURRENT_SOURCE_DIR}/VersionInfo.cpp
with your target's source files? IMO, tampering with the compiler flags
in order to incorporate version information is not the right approach.

Regards,

Michael

> Now the problem: currently CMAKE_CXX_FLAGS_DEBUG is hard-coded. how can 
> i substitute it
> with the current configuration? If it is release then the contents of 
> CMAKE_CXX_FLAGS_RELEASE should
> be taken.
> 
> -Jochen


More information about the CMake mailing list