Generate file version-generated.h when cross compiling too (but there is no support for bzr rev)

This commit is contained in:
Pali Rohár 2013-02-08 14:37:06 +01:00
parent 008611e8e1
commit 0dd75032fc

View file

@ -985,26 +985,36 @@ message("==================================")
# Compile Stratagus
set(genversion_SRCS tools/genversion.cpp)
source_group(genversion FILES ${genversion_SRCS})
add_executable(genversion ${genversion_SRCS})
set_target_properties(genversion PROPERTIES
OUTPUT_NAME "genversion"
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_BINARY_DIR}")
########### next target ###############
add_custom_target(version ALL
${CMAKE_CURRENT_BINARY_DIR}/genversion ${CMAKE_CURRENT_BINARY_DIR}/version-generated.h "${STRATAGUS_VERSION}"
DEPENDS genversion
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
)
add_custom_command(OUTPUT version-generated.h DEPENDS version)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES version-generated.h)
########### next target ###############
if(NOT CMAKE_CROSSCOMPILING)
# Generate header file version-generated.h with bzr revision
# Run tool genversion at compile time which (re)generate file version-generated.h when needed
set(genversion_SRCS tools/genversion.cpp)
source_group(genversion FILES ${genversion_SRCS})
add_executable(genversion ${genversion_SRCS})
add_custom_target(version ALL
genversion ${CMAKE_CURRENT_BINARY_DIR}/version-generated.h "${STRATAGUS_VERSION}"
DEPENDS genversion
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
VERBATIM
)
add_custom_command(OUTPUT version-generated.h DEPENDS version)
list(APPEND CLEAN_FILES version-generated.h)
else()
# Generate header file version-generated.h without bzr revision
# When cross compiling we cannot build host binary, so create file at cmake time
if(NOT "${STRATAGUS_VERSION}" STREQUAL "${STRATAGUS_VERSION_CACHED}" OR NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/version-generated.h)
file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/version-generated.h
"/* ${STRATAGUS_MAJOR_VERSION} ${STRATAGUS_MINOR_VERSION} ${STRATAGUS_PATCH_LEVEL} ${STRATAGUS_PATCH_LEVEL2} -1 */\n"
"/* This file is autogenerated, do not modify it! */\n"
"#define StratagusMajorVersion ${STRATAGUS_MAJOR_VERSION}\n"
"#define StratagusMinorVersion ${STRATAGUS_MINOR_VERSION}\n"
"#define StratagusPatchLevel ${STRATAGUS_PATCH_LEVEL}\n"
"#define StratagusPatchLevel2 ${STRATAGUS_PATCH_LEVEL2}\n"
)
set(STRATAGUS_VERSION_CACHED ${STRATAGUS_VERSION} CACHE INTERNAL "" FORCE)
endif()
list(APPEND CLEAN_FILES version-generated.h)
endif()
add_custom_command(OUTPUT tolua.cpp
COMMAND ${TOLUA++_APP} ARGS -L stratagus.lua -o ${CMAKE_CURRENT_BINARY_DIR}/tolua.cpp stratagus.pkg
@ -1013,8 +1023,6 @@ add_custom_command(OUTPUT tolua.cpp
VERBATIM
)
########### next target ###############
add_executable(stratagus WIN32 ${stratagus_SRCS} ${stratagus_HDRS})
add_dependencies(stratagus version-generated.h)
target_link_libraries(stratagus ${stratagus_LIBS})
@ -1104,7 +1112,7 @@ if(ENABLE_DOC AND DOXYGEN_FOUND)
VERBATIM
)
add_custom_target(doc ALL DEPENDS doxygen/index.html)
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES doxygen)
list(APPEND CLEAN_FILES doxygen)
endif()
########### next target ###############
@ -1173,3 +1181,7 @@ endif(ENABLE_DOC AND DOXYGEN_FOUND)
if(ENABLE_DEV)
install(FILES ${gameheaders_HDRS} DESTINATION ${STRATAGUS_HEADERS})
endif()
########### clean files ###############
set_directory_properties(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${CLEAN_FILES}")