From 0202f40dae4658de8e9935d1a379f02a9372e23c Mon Sep 17 00:00:00 2001 From: leej3 Date: Tue, 26 Feb 2019 15:30:05 -0500 Subject: [PATCH] improve version detection and allow within source build --- CMakeLists.txt | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 70d12d46eb..97f0397e21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,10 +2,19 @@ cmake_minimum_required(VERSION 3.11 FATAL_ERROR) execute_process(COMMAND git "describe" "--tags" OUTPUT_VARIABLE GIT_REPO_VERSION_UNCLEANED - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + ERROR_QUIET) string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+(\\.[0-9]+(\\.g[0-9a-f]+)?)?" GIT_REPO_VERSION "${GIT_REPO_VERSION_UNCLEANED}") +if (GIT_REPO_VERSION STREQUAL "") + if (GIT_DESCRIBE_TAG) + set(GIT_REPO_VERSION ${GIT_DESCRIBE_TAG}) + else() + set(GIT_REPO_VERSION "99.99.99") + endif() +endif() + project(AFNI VERSION ${GIT_REPO_VERSION} DESCRIPTION "A package for the analysis of functional neuroimaging.") @@ -14,11 +23,13 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(BUILD_SHARED_LIBS ON) ### Require out-of-source builds -file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH) -if(EXISTS "${LOC_PATH}") - message(FATAL_ERROR "You cannot build in a source directory (or any directory with a CMakeLists.txt file). Please make a build subdirectory. Feel free to remove CMakeCache.txt and CMakeFiles.") -endif() +# file(TO_CMAKE_PATH "${PROJECT_BINARY_DIR}/CMakeLists.txt" LOC_PATH) +# if(EXISTS "${LOC_PATH}") +# message(FATAL_ERROR "You cannot build in a source directory (or any directory with a CMakeLists.txt file). Please make a build subdirectory. Feel free to remove CMakeCache.txt and CMakeFiles.") +# endif() +# Set policies +cmake_policy(SET CMP0048 NEW) set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DAFNI_DEBUG -DIMSEQ_DEBUG -DDISPLAY_DEBUG -DTHD_DEBUG") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_TRACING") # XXX not in default cflags