Re: [PATCH v4 7/8] cmake: support for building git on windows with msvc and clang

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +#Force all visual studio outputs to CMAKE_BINARY_DIR

What is the reasoning for this? AFAIK this makes it impossible to customize it
from the outside by doing `cmake -DFOO=bar ...`.  

>  if(WIN32)
> -	add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
> -			COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
> -				-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
> -				-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
> -			WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> -			VERBATIM)
> +	if(NOT MSVC)#use windres when compiling with gcc and clang
> +		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
> +				COMMAND ${WINDRES_EXE} -O coff -DMAJOR=${PROJECT_VERSION_MAJOR} -DMINOR=${PROJECT_VERSION_MINOR}
> +					-DMICRO=${PROJECT_VERSION_PATCH} -DPATCHLEVEL=0 -DGIT_VERSION="\\\"${PROJECT_VERSION}.GIT\\\""
> +					-i ${CMAKE_SOURCE_DIR}/git.rc -o ${CMAKE_BINARY_DIR}/git.res
> +				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> +				VERBATIM)
> +	else()#MSVC use rc
> +		add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/git.res
> +				COMMAND ${CMAKE_RC_COMPILER} /d MAJOR=${PROJECT_VERSION_MAJOR} /d MINOR=${PROJECT_VERSION_MINOR}
> +					/d MICRO=${PROJECT_VERSION_PATCH} /d PATCHLEVEL=0 /d GIT_VERSION="${PROJECT_VERSION}.GIT"
> +					/fo ${CMAKE_BINARY_DIR}/git.res ${CMAKE_SOURCE_DIR}/git.rc
> +				WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
> +				VERBATIM)
> +	endif()
>  	add_custom_target(git-rc DEPENDS ${CMAKE_BINARY_DIR}/git.res)
>  endif()

If you list a .rc in the call to add_executable() then CMake knows how to
handle it and will invoke the resource compiler on it. I am not 100% sure how
to provide additional arguments right now, but I believe it will lead to
simpler code than using add_custom_command() and add_custom_target().

Øsse




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux