Commit b6521c67 authored by Alexis Girault's avatar Alexis Girault

WIP: Superbuild Cmake Architecture + g3log

parent 7714bb2d
set( CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_MODULE_PATH} )
include(ExternalProject)
#-----------------------------------------------------------------------------
# Git protocol option
#-----------------------------------------------------------------------------
if(NOT GIT_EXECUTABLE)
find_package(Git REQUIRED)
endif()
option(${PROJECT_NAME}_USE_GIT_PROTOCOL "If behind a firewall turn this OFF to use http instead." ON)
set(git_protocol "git")
if(NOT ${PROJECT_NAME}_USE_GIT_PROTOCOL)
set(git_protocol "http")
endif()
#-----------------------------------------------------------------------------
# CMake global args
#-----------------------------------------------------------------------------
list(APPEND CMAKE_CONFIG_ARGS
-Wno-dev
-DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER:FILEPATH=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER:FILEPATH=${CMAKE_CXX_COMPILER}
-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}
-DCMAKE_EXE_LINKER_FLAGS:STRING=${CMAKE_EXE_LINKER_FLAGS}
-DCMAKE_SHARED_LINKER_FLAGS:STRING=${CMAKE_SHARED_LINKER_FLAGS}
-DCMAKE_INCLUDE_PATH:STRING=${${PROJECT_NAME}_CMAKE_INCLUDE_PATH}
-DCMAKE_LIBRARY_PATH:STRING=${${PROJECT_NAME}_CMAKE_LIBRARY_PATH}
)
#-----------------------------------------------------------------------------
# CMake args if Apple
#-----------------------------------------------------------------------------
if(APPLE)
list(APPEND CMAKE_CONFIG_OSX_ARGS
-DCMAKE_OSX_ARCHITECTURES:STRING=${CMAKE_OSX_ARCHITECTURES}
-DCMAKE_OSX_SYSROOT:PATH=${CMAKE_OSX_SYSROOT}
-DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=${CMAKE_OSX_DEPLOYMENT_TARGET}
-DCMAKE_MACOSX_RPATH:BOOL=ON
)
endif()
#-----------------------------------------------------------------------------
# Solve dependencies
#-----------------------------------------------------------------------------
include(imstkSolveDependencies)
set(EXTERNAL_PROJECT_DIR ${CMAKE_CURRENT_SOURCE_DIR})
ExternalProject_Include_Dependencies( ${PROJECT_NAME}
DEPENDS_VAR ${PROJECT_NAME}_DEPENDENCIES
SUPERBUILD_VAR ${PROJECT_NAME}_SUPERBUILD
)
#-----------------------------------------------------------------------------
# Inner build of the main project
#-----------------------------------------------------------------------------
ExternalProject_Add( ${PROJECT_NAME}
DOWNLOAD_COMMAND ""
INSTALL_COMMAND ""
DOWNLOAD_DIR ${${PROJECT_NAME}_SOURCE_DIR}
SOURCE_DIR ${${PROJECT_NAME}_SOURCE_DIR}
BINARY_DIR ${CMAKE_BINARY_DIR}/${PROJECT_NAME}-${CMAKE_BUILD_TYPE}
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_ARGS
-D${PROJECT_NAME}_SUPERBUILD:BOOL=OFF
# -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS}
# -DBUILD_DOCUMENTATION:BOOL=${BUILD_DOCUMENTATION}
# -DBUILD_EXAMPLES:BOOL=${BUILD_EXAMPLES}
# -DBUILD_TESTING:BOOL=${BUILD_TESTING}
${CMAKE_CONFIG_ARGS}
${CMAKE_CONFIG_OSX_ARGS}
${${PROJECT_NAME}_EXTERNAL_PROJECTS_PATHS}
DEPENDS ${${PROJECT_NAME}_DEPENDENCIES}
)
set(proj Uncrustify)
string(TOUPPER "${proj}" PROJ) set(extProj Uncrustify)
set(${extProj}_DEPENDENCIES "")
set(${extProj}_REPOSITORY ${git_protocol}://github.com/uncrustify/uncrustify.git)
set(${extProj}_GIT_TAG uncrustify-0.62)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Make sure this file is included only once # Sanity checks
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
get_filename_component(CMAKE_CURRENT_LIST_FILENAME ${CMAKE_CURRENT_LIST_FILE} NAME_WE) if(DEFINED ${extProj}_EXECUTABLE AND NOT EXISTS ${${extProj}_EXECUTABLE})
if(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED) message(FATAL_ERROR
return() "${extProj}_EXECUTABLE variable is defined but corresponds to non-existing executable")
endif() endif()
set(${CMAKE_CURRENT_LIST_FILENAME}_FILE_INCLUDED 1)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Sanity checks # Solve dependencies
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
if(DEFINED ${PROJ}_EXECUTABLE AND NOT EXISTS ${${PROJ}_EXECUTABLE}) ExternalProject_Include_Dependencies( ${extProj}
message(FATAL_ERROR "${PROJ}_EXECUTABLE variable is defined but corresponds to non-existing file") PROJECT_VAR extProj
endif() DEPENDS_VAR ${extProj}_DEPENDENCIES
USE_SYSTEM_VAR USE_SYSTEM_${extProj}
SUPERBUILD_VAR ${PROJECT_NAME}_SUPERBUILD
)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Set dependency list # Set extProject directory
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
set(${proj}_DEPENDENCIES "") set(${extProj}_SOURCE_DIR ${CMAKE_BINARY_DIR}/External/${extProj}/src)
set(${extProj}_PREFIX_DIR ${CMAKE_BINARY_DIR}/External/${extProj}/prefix)
set(${extProj}_DIR ${CMAKE_BINARY_DIR}/External/${extProj}/build)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# If needs to download and build # If needs to download and build
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
if(NOT DEFINED ${PROJ}_EXECUTABLE AND NOT ${USE_SYSTEM_${PROJ}}) if(NOT DEFINED ${extProj}_EXECUTABLE AND NOT ${USE_SYSTEM_${extProj}})
#----------------------------------------------------------------------------- set(${extProj}_EXECUTABLE ${${extProj}_DIR}/src/uncrustify)
# Set project Git info
#-----------------------------------------------------------------------------
set(${proj}_REPOSITORY ${git_protocol}://github.com/uncrustify/uncrustify.git)
set(${proj}_GIT_TAG uncrustify-0.62)
#-----------------------------------------------------------------------------
# Set project directory
#-----------------------------------------------------------------------------
set(${proj}_SOURCE_DIR ${CMAKE_BINARY_DIR}/Superbuild/${proj}-src)
set(${proj}_PREFIX_DIR ${CMAKE_BINARY_DIR}/Superbuild/${proj}-prefix)
set(${proj}_DIR ${CMAKE_BINARY_DIR}/Superbuild/${proj}-build)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Add project # Add extProject
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
include(ExternalProject) ExternalProject_add(${extProj}
ExternalProject_add(${proj} GIT_REPOSITORY ${${extProj}_REPOSITORY}
GIT_REPOSITORY ${${proj}_REPOSITORY} GIT_TAG ${${extProj}_GIT_TAG}
GIT_TAG ${${proj}_GIT_TAG} SOURCE_DIR ${${extProj}_SOURCE_DIR}
BINARY_DIR ${${extProj}_DIR}
PREFIX ${${extProj}_PREFIX_DIR}
UPDATE_COMMAND "" UPDATE_COMMAND ""
PREFIX ${${proj}_PREFIX_DIR} INSTALL_COMMAND ""
SOURCE_DIR ${${proj}_SOURCE_DIR}
BINARY_DIR ${${proj}_DIR}
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<BINARY_DIR> #TODO: does not work on Windows, see --host= option CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<BINARY_DIR> #TODO: does not work on Windows, see --host= option
DEPENDS ${${proj}_DEPENDENCIES} DEPENDS ${${extProj}_DEPENDENCIES}
) )
set(${PROJ}_EXECUTABLE ${${proj}_DIR}/bin/uncrustify)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# If using system # If using system
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
else() elseif(${USE_SYSTEM_${extProj}})
if(${USE_SYSTEM_${PROJ}})
find_program(${PROJ}_EXECUTABLE ${proj} DOC "Path of ${proj} program") find_program(${extProj}_EXECUTABLE ${extProj} DOC "Path of ${extProj} program")
if(NOT ${PROJ}_EXECUTABLE) if(NOT ${extProj}_EXECUTABLE)
message(FATAL_ERROR "To use the system ${proj}, set ${PROJ}_EXECUTABLE") message(FATAL_ERROR "To use the system ${extProj}, set ${extProj}_EXECUTABLE")
endif()
endif() endif()
#-----------------------------------------------------------------------------
# Add empty project (to solve dependencies)
#-----------------------------------------------------------------------------
ExternalProject_Add(${project_name}
SOURCE_DIR ${${extProj}_SOURCE_DIR}
BINARY_DIR ${${extProj}_DIR}
PREFIX ${${extProj}_PREFIX_DIR}
DOWNLOAD_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
DEPENDS ${${extProj}_DEPENDENCIES}
)
endif() endif()
set(TEST true)
#-----------------------------------------------------------------------------
# Keep track of project path to add it in the superbuild cache
#-----------------------------------------------------------------------------
list( APPEND ${PROJECT_NAME}_EXTERNAL_PROJECTS_PATHS -D${extProj}_EXECUTABLE:PATH=${${extProj}_EXECUTABLE} )
#-----------------------------------------------------------------------------
# Add External Project
#-----------------------------------------------------------------------------
include(imstkAddExternalProject)
imstk_add_external_project( g3log
REPOSITORY ${git_protocol}://github.com/KjellKod/g3log.git
GIT_TAG 579579962c94213a46fadbb70a996f08c19be3a2
#DEPENDENCIES ""
#VERBOSE
)
#-----------------------------------------------------------------------------
# Find path
#-----------------------------------------------------------------------------
find_path(g3log_INCLUDE_DIR
NAMES
g3log/g3log.hpp
g3log/logworker.hpp
)
mark_as_advanced(g3log_INCLUDE_DIR)
#-----------------------------------------------------------------------------
# Find library
#-----------------------------------------------------------------------------
find_library(g3log_LIBRARY
NAMES
g3logger_shared)
mark_as_advanced(g3log_LIBRARY)
#-----------------------------------------------------------------------------
# Find package
#-----------------------------------------------------------------------------
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(g3log
REQUIRED_VARS
g3log_INCLUDE_DIR
g3log_LIBRARY)
#-----------------------------------------------------------------------------
# If missing target, create it
#-----------------------------------------------------------------------------
if(G3LOG_FOUND AND NOT TARGET g3log::g3log)
add_library(g3log::g3log INTERFACE IMPORTED)
set_target_properties(g3log::g3log PROPERTIES
INTERFACE_LINK_LIBRARIES "${g3log_LIBRARY}"
INTERFACE_INCLUDE_DIRECTORIES "${g3log_INCLUDE_DIR}")
endif()
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Define configuration files # Define configuration files
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
set(UNCRUSTIFY_CONFIG "${CMAKE_SOURCE_DIR}/Utilities/Uncrustify/${PROJECT_NAME}Uncrustify.cfg") set(Uncrustify_CONFIG "${CMAKE_SOURCE_DIR}/Utilities/Uncrustify/${PROJECT_NAME}Uncrustify.cfg")
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Setup git hook for Uncrustify executable path # Setup git hook for Uncrustify executable path
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
find_package(Git) find_package(Git)
if(GIT_FOUND) if(GIT_FOUND)
if(EXISTS "${UNCRUSTIFY_EXECUTABLE}" AND EXISTS "${UNCRUSTIFY_CONFIG}") if(EXISTS "${Uncrustify_EXECUTABLE}" AND EXISTS "${Uncrustify_CONFIG}")
message(STATUS "Uncrustify found: enabling in git hook") message(STATUS "Uncrustify found: enabling in git hook")
execute_process(COMMAND ${GIT_EXECUTABLE} config uncrustify.path "${UNCRUSTIFY_EXECUTABLE}" execute_process(COMMAND ${GIT_EXECUTABLE} config uncrustify.path "${Uncrustify_EXECUTABLE}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
) )
execute_process(COMMAND ${GIT_EXECUTABLE} config uncrustify.conf "${UNCRUSTIFY_CONFIG}" execute_process(COMMAND ${GIT_EXECUTABLE} config uncrustify.conf "${Uncrustify_CONFIG}"
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
) )
execute_process( COMMAND ${GIT_EXECUTABLE} config uncrustify.enabled true execute_process( COMMAND ${GIT_EXECUTABLE} config uncrustify.enabled true
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
) )
else() else()
if(NOT EXISTS "${UNCRUSTIFY_EXECUTABLE}") if(NOT EXISTS "${Uncrustify_EXECUTABLE}")
message(STATUS "Uncrustify executable not found: disabling in git hook") message(STATUS "Uncrustify executable not found: disabling in git hook")
execute_process(COMMAND ${GIT_EXECUTABLE} config --unset uncrustify.path execute_process(COMMAND ${GIT_EXECUTABLE} config --unset uncrustify.path
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
) )
endif() endif()
if(NOT EXISTS "${UNCRUSTIFY_CONFIG}") if(NOT EXISTS "${Uncrustify_CONFIG}")
message(STATUS "Uncrustify config file not found: disabling in git hook") message(STATUS "Uncrustify config file not found: disabling in git hook")
execute_process(COMMAND ${GIT_EXECUTABLE} config --unset uncrustify.conf execute_process(COMMAND ${GIT_EXECUTABLE} config --unset uncrustify.conf
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
......
macro(imstk_add_external_project extProj)
set(options VERBOSE)
set(oneValueArgs REPOSITORY GIT_TAG)
set(multiValueArgs DEPENDENCIES)
include(CMakeParseArguments)
cmake_parse_arguments(${extProj} "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
#-----------------------------------------------------------------------------
# Verbose (display arguments)
#-----------------------------------------------------------------------------
if(${extProj}_VERBOSE)
foreach(opt ${options} ${oneValueArgs} ${multiValueArgs})
message(STATUS "${extProj}_${opt}:${${extProj}_${opt}}")
endforeach()
endif()
#-----------------------------------------------------------------------------
# Sanity checks
#-----------------------------------------------------------------------------
if(DEFINED ${extProj}_DIR AND NOT EXISTS ${${extProj}_DIR})
message(FATAL_ERROR
"${extProj}_DIR variable is defined but corresponds to non-existing directory")
endif()
#-----------------------------------------------------------------------------
# Solve dependencies
#-----------------------------------------------------------------------------
set(PROJECT_VAR_TEMP ${extProj})
ExternalProject_Include_Dependencies( ${extProj}
PROJECT_VAR PROJECT_VAR_TEMP
DEPENDS_VAR ${extProj}_DEPENDENCIES
USE_SYSTEM_VAR USE_SYSTEM_${extProj}
SUPERBUILD_VAR ${PROJECT_NAME}_SUPERBUILD
)
#-----------------------------------------------------------------------------
# If needs to download and build
#-----------------------------------------------------------------------------
if(NOT DEFINED ${extProj}_DIR AND NOT ${USE_SYSTEM_${extProj}})
#-----------------------------------------------------------------------------
# Set project directory
#-----------------------------------------------------------------------------
set(${extProj}_SOURCE_DIR ${CMAKE_BINARY_DIR}/External/${extProj}/src)
set(${extProj}_PREFIX_DIR ${CMAKE_BINARY_DIR}/External/${extProj}/prefix)
set(${extProj}_DIR ${CMAKE_BINARY_DIR}/External/${extProj}/build-${CMAKE_BUILD_TYPE})
#-----------------------------------------------------------------------------
# Add project
#-----------------------------------------------------------------------------
ExternalProject_add( ${extProj}
SOURCE_DIR ${${extProj}_SOURCE_DIR}
BINARY_DIR ${${extProj}_DIR}
PREFIX ${${extProj}_PREFIX_DIR}
GIT_REPOSITORY ${${extProj}_REPOSITORY}
GIT_TAG ${${extProj}_GIT_TAG}
UPDATE_COMMAND ""
INSTALL_COMMAND ""
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_ARGS
${CMAKE_CONFIG_ARGS}
${CMAKE_CONFIG_OSX_ARGS}
#-DBUILD_SHARED_LIBS:BOOL=${shared}
#-DBUILD_EXAMPLES:BOOL=OFF
#-DBUILD_TESTING:BOOL=OFF
DEPENDS ${${extProj}_DEPENDENCIES}
)
#-----------------------------------------------------------------------------
# If project already built on system
#-----------------------------------------------------------------------------
else()
if( ${USE_SYSTEM_${extProj}} )
find_package( ${extProj} REQUIRED )
endif()
#-----------------------------------------------------------------------------
# Add empty project (to solve dependencies)
#-----------------------------------------------------------------------------
ExternalProject_Add(${project_name}
SOURCE_DIR ${${extProj}_SOURCE_DIR}
BINARY_DIR ${${extProj}_DIR}
PREFIX ${${extProj}_PREFIX_DIR}
DOWNLOAD_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
DEPENDS ${${extProj}_DEPENDENCIES}
)
endif()
#-----------------------------------------------------------------------------
# Keep track of project path to add it in the superbuild cache
#-----------------------------------------------------------------------------
list( APPEND ${PROJECT_NAME}_EXTERNAL_PROJECTS_PATHS -D${extProj}_DIR:PATH=${${extProj}_DIR} )
endmacro()
...@@ -3,6 +3,7 @@ function(imstk_add_library target) ...@@ -3,6 +3,7 @@ function(imstk_add_library target)
set(options VERBOSE) set(options VERBOSE)
set(oneValueArgs) set(oneValueArgs)
set(multiValueArgs H_FILES CPP_FILES LIBRARIES) set(multiValueArgs H_FILES CPP_FILES LIBRARIES)
include(CMakeParseArguments)
cmake_parse_arguments(target "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} ) cmake_parse_arguments(target "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
message(STATUS "Configuring ${target}") message(STATUS "Configuring ${target}")
...@@ -15,7 +16,7 @@ function(imstk_add_library target) ...@@ -15,7 +16,7 @@ function(imstk_add_library target)
message(STATUS "${opt}:${target_${opt}}") message(STATUS "${opt}:${target_${opt}}")
endforeach() endforeach()
endif() endif()
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Create target (library) # Create target (library)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
...@@ -23,14 +24,14 @@ function(imstk_add_library target) ...@@ -23,14 +24,14 @@ function(imstk_add_library target)
${target_H_FILES} ${target_H_FILES}
${target_CPP_FILES} ${target_CPP_FILES}
) )
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Link libraries to current target # Link libraries to current target
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
target_link_libraries( ${target} target_link_libraries( ${target}
${target_LIBRARIES} ${target_LIBRARIES}
) )
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Include directories # Include directories
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
...@@ -58,4 +59,3 @@ function(imstk_add_library target) ...@@ -58,4 +59,3 @@ function(imstk_add_library target)
) )
endfunction() endfunction()
This diff is collapsed.
cmake_minimum_required(VERSION 3.2) cmake_minimum_required(VERSION 3.2)
project(iMSTK VERSION 0.0.1 LANGUAGES CXX) project(iMSTK VERSION 0.0.1 LANGUAGES C CXX)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Update CMake module path & cmake dir # Update CMake module path & cmake dir
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
set(CMAKE_MODULE_PATH set(CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/CMake ${CMAKE_CURRENT_SOURCE_DIR}/CMake
${CMAKE_CURRENT_SOURCE_DIR}/CMake/Superbuild ${CMAKE_CURRENT_SOURCE_DIR}/CMake/Utilities
${CMAKE_MODULE_PATH} ${CMAKE_MODULE_PATH}
) )
set(${PROJECT_NAME}_CMAKE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMake) set(${PROJECT_NAME}_CMAKE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/CMake)
...@@ -58,48 +58,44 @@ else() ...@@ -58,48 +58,44 @@ else()
endif() endif()
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Git protocol option # Define External dependencies
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
if(NOT GIT_EXECUTABLE) # g3log
find_package(Git REQUIRED) list(APPEND ${PROJECT_NAME}_DEPENDENCIES g3log)
endif() option(USE_SYSTEM_g3log "Exclude g3log from superbuild and use an existing build." OFF)
mark_as_advanced(USE_SYSTEM_g3log)
option(${PROJECT_NAME}_USE_GIT_PROTOCOL "If behind a firewall turn this OFF to use http instead." ON)
set(git_protocol "git")
if(NOT ${PROJECT_NAME}_USE_GIT_PROTOCOL)
set(git_protocol "http")
endif()
#-----------------------------------------------------------------------------
# Define ThirdParty dependencies
#-----------------------------------------------------------------------------
# Uncrustify # Uncrustify
option(${PROJECT_NAME}_USE_UNCRUSTIFY "Use Uncrustify to check for coding standards violations." ON) list(APPEND ${PROJECT_NAME}_DEPENDENCIES Uncrustify)
option(USE_SYSTEM_UNCRUSTIFY "Exclude Uncrustify from superbuild and use an existing build." OFF) option(USE_SYSTEM_Uncrustify "Exclude Uncrustify from superbuild and use an existing build." OFF)
mark_as_advanced(USE_SYSTEM_UNCRUSTIFY) mark_as_advanced(USE_SYSTEM_Uncrustify)
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Superbuild # SUPERBUILD
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
option(${PROJECT_NAME}_SUPERBUILD "Build ${PROJECT_NAME} and the projects it depends on." ON) option(${PROJECT_NAME}_SUPERBUILD "Build ${PROJECT_NAME} and the projects it depends on." ON)
mark_as_advanced(${PROJECT_NAME}_SUPERBUILD)
set(${PROJECT_NAME}_BINARY_INNER_SUBDIR ${PROJECT_NAME}-build)
if(${PROJECT_NAME}_SUPERBUILD) if(${PROJECT_NAME}_SUPERBUILD)
# Call CMakeLists.txt in CMake/External which will solve the dependencies
if(${PROJECT_NAME}_USE_UNCRUSTIFY) # and add the External projects, including this one: this top-level
include(External_Uncrustify) # CMakeLists.txt will be called back with SUPERBUILD=OFF, to execute
endif() # the rest of the code below (INNERBUILD), which explains the `return`
add_subdirectory(CMake/External)
return()
endif() endif()
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# Include ThirdParty dependencies # INNERBUILD
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
# Find external dependencies
#----------------------------------------------------------------------------- #-----------------------------------------------------------------------------
# g3log
find_package( g3log REQUIRED )
include_directories( ${g3log_INCLUDE_DIRS} )
# Uncrustify # Uncrustify
if(${PROJECT_NAME}_USE_UNCRUSTIFY) include(SetupUncrustifyConfig)
include(SetupUncrustifyHook)
endif()
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# Add Source code subdirectories # Add Source code subdirectories
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment