mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-02-06 16:58:02 +08:00
cmake git ver depend on index and HEAD
This commit is contained in:
committed by
Lorenz Meier
parent
159b35919a
commit
dcddcdd28e
@@ -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("On Ubuntu 16.04, install or upgrade via:")
|
||||
message("On Ubuntu >= 16.04, install or upgrade via:")
|
||||
message(" sudo apt-get install cmake")
|
||||
message("")
|
||||
message("Official website:")
|
||||
message(" wget https://cmake.org/files/v3.4/cmake-3.4.3-Linux-x86_64.sh")
|
||||
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")
|
||||
message("Official website: https://cmake.org/download/")
|
||||
message(FATAL_ERROR "Update CMake and try again" )
|
||||
endif()
|
||||
|
||||
# Warning: Changing this modifies CMake's internal workings
|
||||
# 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_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
|
||||
STRINGS ";Debug;Release;RelWithDebInfo;MinSizeRel")
|
||||
set(CONFIG "posix_sitl_default" CACHE STRING "desired configuration")
|
||||
|
||||
file(GLOB_RECURSE configs RELATIVE cmake/configs "cmake/configs/*.cmake")
|
||||
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(EXTERNAL_MODULES_LOCATION "" CACHE STRING "External modules source location")
|
||||
|
||||
@@ -247,14 +244,6 @@ set(BUILD_SHARED_LIBS OFF)
|
||||
# project definition
|
||||
#
|
||||
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")
|
||||
|
||||
@@ -289,6 +278,15 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
|
||||
#=============================================================================
|
||||
# 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
|
||||
CMAKE_C_COMPILER_ID
|
||||
)
|
||||
@@ -495,7 +493,7 @@ endif()
|
||||
#=============================================================================
|
||||
# generate git version
|
||||
#
|
||||
px4_create_git_hash_header(OUT ${PX4_BINARY_DIR}/build_git_version.h)
|
||||
px4_create_git_hash_header()
|
||||
|
||||
#=============================================================================
|
||||
# packaging
|
||||
|
||||
@@ -826,14 +826,14 @@ function(px4_add_common_flags)
|
||||
-g
|
||||
-fno-exceptions
|
||||
-fno-rtti
|
||||
-std=gnu++0x
|
||||
-std=gnu++11
|
||||
-fno-threadsafe-statics
|
||||
-DCONFIG_WCHAR_BUILTIN
|
||||
-D__CUSTOM_FILE_IO__
|
||||
)
|
||||
|
||||
# clang
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
# regular Clang or AppleClang
|
||||
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
|
||||
# force color for clang (needed for clang + ccache)
|
||||
list(APPEND _optimization_flags
|
||||
-fcolor-diagnostics
|
||||
@@ -973,29 +973,27 @@ endfunction()
|
||||
# Create a header file containing the git hash of the current tree
|
||||
#
|
||||
# Usage:
|
||||
# px4_create_git_hash_header(HEADER ${CMAKE_BUILD_DIR}/git_hash.h)
|
||||
#
|
||||
# Input:
|
||||
# HEADER : path of the header file to generate
|
||||
# px4_create_git_hash_header()
|
||||
#
|
||||
# Example:
|
||||
# px4_create_git_hash_header(HEADER ${CMAKE_BUILD_DIR}/git_hash.h)
|
||||
# px4_create_git_hash_header()
|
||||
#
|
||||
function(px4_create_git_hash_header)
|
||||
px4_parse_function_args(
|
||||
NAME px4_create_git_hash_header
|
||||
ONE_VALUE OUT
|
||||
REQUIRED OUT
|
||||
ARGN ${ARGN})
|
||||
file(WRITE ${OUT} "")
|
||||
|
||||
set(px4_git_ver_header ${PX4_BINARY_DIR}/build_git_version.h)
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT __fake
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/px_update_git_header.py ${OUT} > ${PX4_BINARY_DIR}/git_header.log
|
||||
OUTPUT ${px4_git_ver_header}
|
||||
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}
|
||||
COMMENT "Generating git hash header"
|
||||
)
|
||||
add_custom_target(ver_gen ALL
|
||||
DEPENDS ${OUT} __fake)
|
||||
set_source_files_properties(${px4_git_ver_header} PROPERTIES GENERATED TRUE)
|
||||
add_custom_target(ver_gen ALL DEPENDS ${px4_git_ver_header})
|
||||
endfunction()
|
||||
|
||||
#=============================================================================
|
||||
|
||||
@@ -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 )
|
||||
endif()
|
||||
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
|
||||
add_compile_options(-Qunused-arguments)
|
||||
endif()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user