Skip to content

Commit

Permalink
Improve cmake timestamp and git csv retrieval to avoid useless rebuild
Browse files Browse the repository at this point in the history
- Before, visp-build-info.tmp was modified after each call to cmake leading
  to rebuilding vpIoTools.cpp and thus visp_core...
- Now visp-build-info.tmp is updated only if necessary
- This commit removes also all specific cmake code when cmake < 2.8.12
  • Loading branch information
fspindle committed Oct 21, 2023
1 parent 8b0ad17 commit f44b4b7
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 36 deletions.
22 changes: 7 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1262,16 +1262,7 @@ vp_system_information(NUMBER_OF_LOGICAL_CORES NUMBER_OF_PHYSICAL_CORES TOTAL_PHY
find_host_package(Git QUIET)

if(NOT DEFINED VISP_VCSVERSION AND GIT_FOUND)
execute_process(COMMAND "${GIT_EXECUTABLE}" describe --tags --always --dirty --match "v[0-9].[0-9].[0-9]*"
WORKING_DIRECTORY "${VISP_SOURCE_DIR}"
OUTPUT_VARIABLE VISP_VCSVERSION
RESULT_VARIABLE GIT_RESULT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT GIT_RESULT EQUAL 0)
set(VISP_VCSVERSION "unknown")
endif()
vp_git_describe(VISP_VCSVERSION "${VISP_SOURCE_DIR}")
elseif(NOT DEFINED VISP_VCSVERSION)
# We don't have git:
set(VISP_VCSVERSION "unknown")
Expand Down Expand Up @@ -1322,11 +1313,12 @@ endif()
# ========================== build platform ==========================
status("")
status(" Platform:")
if(NOT CMAKE_VERSION VERSION_LESS 2.8.11)
string(TIMESTAMP TIMESTAMP "" UTC)
if(TIMESTAMP)
status(" Timestamp:" ${TIMESTAMP})
endif()
if(NOT DEFINED VISP_TIMESTAMP AND NOT BUILD_INFO_SKIP_TIMESTAMP)
string(TIMESTAMP VISP_TIMESTAMP "" UTC)
set(VISP_TIMESTAMP "${VISP_TIMESTAMP}" CACHE STRING "Timestamp of ViSP build configuration" FORCE)
endif()
if(VISP_TIMESTAMP)
status(" Timestamp:" ${VISP_TIMESTAMP})
endif()
status(" Host:" ${CMAKE_HOST_SYSTEM_NAME} ${CMAKE_HOST_SYSTEM_VERSION} ${CMAKE_HOST_SYSTEM_PROCESSOR})
if(CMAKE_CROSSCOMPILING)
Expand Down
10 changes: 0 additions & 10 deletions cmake/VISPModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -590,11 +590,6 @@ macro(vp_target_include_modules target)
if(d MATCHES "^visp_" AND HAVE_${d})
if (EXISTS "${VISP_MODULE_${d}_LOCATION}/include")
vp_target_include_directories(${target} "${VISP_MODULE_${d}_LOCATION}/include")
# Work around to be able to build the modules without INTERFACE_INCLUDE_DIRECTORIES
# that was only introduces since CMake 2.8.12
if (CMAKE_VERSION VERSION_LESS 2.8.12)
vp_target_include_directories(${target} "${VISP_MODULE_${d}_INC_DEPS}")
endif()
endif()
elseif(EXISTS "${d}")
# FS keep external deps inc
Expand Down Expand Up @@ -992,11 +987,6 @@ macro(vp_add_tests)
foreach(d ${VISP_TEST_${the_module}_DEPS})
list(APPEND test_deps ${d})
list(APPEND test_deps ${VISP_MODULE_${d}_DEPS})
# Work around to be able to build the modules without INTERFACE_INCLUDE_DIRECTORIES
# that was only introduces since CMake 2.8.12
if(CMAKE_VERSION VERSION_LESS 2.8.12)
list(APPEND test_deps "${VISP_MODULE_${__m}_INC_DEPS}")
endif()
endforeach()

vp_check_dependencies(${test_deps})
Expand Down
35 changes: 27 additions & 8 deletions cmake/VISPUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -195,15 +195,11 @@ function(vp_target_include_directories target)
endif()
endforeach()
if(__params)
if(CMAKE_VERSION VERSION_LESS 2.8.11)
include_directories(${__params})
if(TARGET ${target})
target_include_directories(${target} PRIVATE ${__params})
else()
if(TARGET ${target})
target_include_directories(${target} PRIVATE ${__params})
else()
set(__new_inc "${VP_TARGET_INCLUDE_DIRS_${target}};${__params}")
set(VP_TARGET_INCLUDE_DIRS_${target} "${__new_inc}" CACHE INTERNAL "")
endif()
set(__new_inc "${VP_TARGET_INCLUDE_DIRS_${target}};${__params}")
set(VP_TARGET_INCLUDE_DIRS_${target} "${__new_inc}" CACHE INTERNAL "")
endif()
endif()
endfunction()
Expand Down Expand Up @@ -1969,3 +1965,26 @@ macro(vp_list_replace_string list_in list_out regular_expression replacement_exp
endforeach()
set(${list_out} ${__list_out})
endmacro()

macro(vp_git_describe var_name path)
if(GIT_FOUND)
execute_process(COMMAND "${GIT_EXECUTABLE}" describe --tags --exact-match --dirty
WORKING_DIRECTORY "${path}"
OUTPUT_VARIABLE ${var_name}
RESULT_VARIABLE GIT_RESULT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if(NOT GIT_RESULT EQUAL 0)
execute_process(COMMAND "${GIT_EXECUTABLE}" describe --tags --always --dirty --match "[0-9].[0-9].[0-9]*"
WORKING_DIRECTORY "${path}"
OUTPUT_VARIABLE ${var_name}
RESULT_VARIABLE GIT_RESULT
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
endif()
else()
set(${var_name} "unknown")
endif()
endmacro()
3 changes: 0 additions & 3 deletions platforms/android/android.toolchain.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -1156,9 +1156,6 @@ if( NOT CMAKE_C_COMPILER )
endif()

set( _CMAKE_TOOLCHAIN_PREFIX "${ANDROID_TOOLCHAIN_MACHINE_NAME}-" )
if( CMAKE_VERSION VERSION_LESS 2.8.5 )
set( CMAKE_ASM_COMPILER_ARG1 "-c" )
endif()
if( APPLE )
find_program( CMAKE_INSTALL_NAME_TOOL NAMES install_name_tool )
if( NOT CMAKE_INSTALL_NAME_TOOL )
Expand Down

0 comments on commit f44b4b7

Please sign in to comment.