Browse Source

cmake git ver depend on index and HEAD

sbg
Daniel Agar 8 years ago committed by Lorenz Meier
parent
commit
dcddcdd28e
  1. 38
      CMakeLists.txt
  2. 28
      cmake/common/px4_base.cmake
  3. 6
      unittests/CMakeLists.txt

38
CMakeLists.txt

@ -117,22 +117,18 @@
# #
#============================================================================= #=============================================================================
if("${CMAKE_VERSION}" VERSION_LESS 2.8.0) if("${CMAKE_VERSION}" VERSION_LESS 3.1.0)
message("Not a valid CMake version") message("Not a valid CMake version")
message("On Ubuntu 16.04, install or upgrade via:") message("On Ubuntu >= 16.04, install or upgrade via:")
message(" sudo apt-get install cmake") message(" sudo apt-get install cmake")
message("") message("")
message("Official website:") message("Official website: https://cmake.org/download/")
message(" wget https://cmake.org/files/v3.4/cmake-3.4.3-Linux-x86_64.sh") message(FATAL_ERROR "Update CMake and try again" )
message(" chmod +x cmake-3.4.3-Linux-x86_64.sh")
message(" sudo mkdir /opt/cmake-3.4.3")
message(" sudo ./cmake-3.4.3-Linux-x86_64.sh --prefix=/opt/cmake-3.4.3 --exclude-subdir")
message(" export PATH=/opt/cmake-3.4.3/bin:$$PATH")
endif() endif()
# Warning: Changing this modifies CMake's internal workings # Warning: Changing this modifies CMake's internal workings
# and leads to wrong toolchain detection # and leads to wrong toolchain detection
cmake_minimum_required(VERSION 2.8 FATAL_ERROR) cmake_minimum_required(VERSION 3.1 FATAL_ERROR)
set(PX4_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") set(PX4_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}")
set(PX4_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}") set(PX4_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
@ -150,10 +146,11 @@ set(CMAKE_BUILD_TYPE "" CACHE STRING "build type")
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY set_property(CACHE CMAKE_BUILD_TYPE PROPERTY
STRINGS ";Debug;Release;RelWithDebInfo;MinSizeRel") STRINGS ";Debug;Release;RelWithDebInfo;MinSizeRel")
set(CONFIG "posix_sitl_default" CACHE STRING "desired configuration") set(CONFIG "posix_sitl_default" CACHE STRING "desired configuration")
file(GLOB_RECURSE configs RELATIVE cmake/configs "cmake/configs/*.cmake") file(GLOB_RECURSE configs RELATIVE cmake/configs "cmake/configs/*.cmake")
set_property(CACHE CONFIG PROPERTY STRINGS ${configs}) set_property(CACHE CONFIG PROPERTY STRINGS ${configs})
set(THREADS "4" CACHE STRING
"number of threads to use for external build processes") set(THREADS "4" CACHE STRING "number of threads to use for external build processes")
set(DEBUG_PORT "/dev/ttyACM0" CACHE STRING "debugging port") set(DEBUG_PORT "/dev/ttyACM0" CACHE STRING "debugging port")
set(EXTERNAL_MODULES_LOCATION "" CACHE STRING "External modules source location") set(EXTERNAL_MODULES_LOCATION "" CACHE STRING "External modules source location")
@ -247,14 +244,6 @@ set(BUILD_SHARED_LIBS OFF)
# project definition # project definition
# #
project(px4 CXX C ASM) project(px4 CXX C ASM)
if (NOT ${CMAKE_VERSION} VERSION_LESS 3.0.0)
cmake_policy(SET CMP0045 NEW) # error on non-existent target in get prop
cmake_policy(SET CMP0046 NEW) # no non-existent targets as dependencies
cmake_policy(SET CMP0025 OLD) # still report AppleClang as Clang
endif()
if (NOT ${CMAKE_VERSION} VERSION_LESS 3.1.0)
cmake_policy(SET CMP0054 NEW) # don't dereference quoted variables
endif()
set(package-contact "px4users@googlegroups.com") set(package-contact "px4users@googlegroups.com")
@ -289,6 +278,15 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
#============================================================================= #=============================================================================
# check required toolchain variables # check required toolchain variables
# #
# PX4 requires c++11
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# PX4 requires c99
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(required_variables set(required_variables
CMAKE_C_COMPILER_ID CMAKE_C_COMPILER_ID
) )
@ -495,7 +493,7 @@ endif()
#============================================================================= #=============================================================================
# generate git version # generate git version
# #
px4_create_git_hash_header(OUT ${PX4_BINARY_DIR}/build_git_version.h) px4_create_git_hash_header()
#============================================================================= #=============================================================================
# packaging # packaging

28
cmake/common/px4_base.cmake

@ -826,14 +826,14 @@ function(px4_add_common_flags)
-g -g
-fno-exceptions -fno-exceptions
-fno-rtti -fno-rtti
-std=gnu++0x -std=gnu++11
-fno-threadsafe-statics -fno-threadsafe-statics
-DCONFIG_WCHAR_BUILTIN -DCONFIG_WCHAR_BUILTIN
-D__CUSTOM_FILE_IO__ -D__CUSTOM_FILE_IO__
) )
# clang # regular Clang or AppleClang
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# force color for clang (needed for clang + ccache) # force color for clang (needed for clang + ccache)
list(APPEND _optimization_flags list(APPEND _optimization_flags
-fcolor-diagnostics -fcolor-diagnostics
@ -973,29 +973,27 @@ endfunction()
# Create a header file containing the git hash of the current tree # Create a header file containing the git hash of the current tree
# #
# Usage: # Usage:
# px4_create_git_hash_header(HEADER ${CMAKE_BUILD_DIR}/git_hash.h) # px4_create_git_hash_header()
#
# Input:
# HEADER : path of the header file to generate
# #
# Example: # Example:
# px4_create_git_hash_header(HEADER ${CMAKE_BUILD_DIR}/git_hash.h) # px4_create_git_hash_header()
# #
function(px4_create_git_hash_header) function(px4_create_git_hash_header)
px4_parse_function_args( px4_parse_function_args(
NAME px4_create_git_hash_header NAME px4_create_git_hash_header
ONE_VALUE OUT
REQUIRED OUT
ARGN ${ARGN}) ARGN ${ARGN})
file(WRITE ${OUT} "")
set(px4_git_ver_header ${PX4_BINARY_DIR}/build_git_version.h)
add_custom_command( add_custom_command(
OUTPUT __fake OUTPUT ${px4_git_ver_header}
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_update_git_header.py ${OUT} > ${PX4_BINARY_DIR}/git_header.log COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_update_git_header.py ${px4_git_ver_header} > ${PX4_BINARY_DIR}/git_header.log
DEPENDS ${PX4_SOURCE_DIR}/Tools/px_update_git_header.py ${PX4_SOURCE_DIR}/.git/index ${PX4_SOURCE_DIR}/.git/HEAD
WORKING_DIRECTORY ${PX4_SOURCE_DIR} WORKING_DIRECTORY ${PX4_SOURCE_DIR}
COMMENT "Generating git hash header" COMMENT "Generating git hash header"
) )
add_custom_target(ver_gen ALL set_source_files_properties(${px4_git_ver_header} PROPERTIES GENERATED TRUE)
DEPENDS ${OUT} __fake) add_custom_target(ver_gen ALL DEPENDS ${px4_git_ver_header})
endfunction() endfunction()
#============================================================================= #=============================================================================

6
unittests/CMakeLists.txt

@ -1,9 +1,9 @@
cmake_minimum_required(VERSION 2.8) cmake_minimum_required(VERSION 3.1)
if("${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") if("${CMAKE_C_COMPILER_ID}" MATCHES "Clang")
add_compile_options(-Qunused-arguments ) add_compile_options(-Qunused-arguments )
endif() endif()
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
add_compile_options(-Qunused-arguments) add_compile_options(-Qunused-arguments)
endif() endif()

Loading…
Cancel
Save