* Updated format of cmake files * Added support for sanitizersmaster
@@ -0,0 +1,6 @@ | |||||
{ | |||||
"files.trimTrailingWhitespace": true, | |||||
"files.trimFinalNewlines": true, | |||||
"files.insertFinalNewline": true, | |||||
"files.eol": "\n" | |||||
} |
@@ -1,30 +1,29 @@ | |||||
# Initialize CMake ################################################################################ | # Initialize CMake ################################################################################ | ||||
CMake_Minimum_Required ( VERSION 3.12.0 FATAL_ERROR ) | |||||
CMake_Minimum_Required ( VERSION 3.12.0 FATAL_ERROR ) | |||||
# Set CMAKE_BUILD_TYPE | # Set CMAKE_BUILD_TYPE | ||||
If ( NOT CMAKE_BUILD_TYPE ) | |||||
Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE ) | |||||
EndIf ( NOT CMAKE_BUILD_TYPE ) | |||||
Set_Property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel ) | |||||
If ( NOT CMAKE_BUILD_TYPE ) | |||||
Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE ) | |||||
EndIf ( NOT CMAKE_BUILD_TYPE ) | |||||
Set_Property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel ) | |||||
# Set CMAKE_MODULE_PATH | # Set CMAKE_MODULE_PATH | ||||
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
EndIf ( ) | |||||
EndIf ( ) | |||||
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) | |||||
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) | |||||
EndIf ( ) | |||||
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/cmake" ) | |||||
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/cmake" ) | |||||
EndIf ( ) | |||||
# Includes | # Includes | ||||
Include ( CTest ) | |||||
Include ( GNUInstallDirs ) | |||||
Include ( CTest ) | |||||
Include ( GNUInstallDirs ) | |||||
# Projects ######################################################################################## | # Projects ######################################################################################## | ||||
Message ( WARNING "Please configure the subprojects of this project group!" ) | |||||
# Find_Package ( <package> ) | |||||
Message ( WARNING "Please configure the subprojects of this project group!" ) | |||||
# Find_Package ( <package> ) |
@@ -0,0 +1 @@ | |||||
TODO: write a docu :) |
@@ -1 +1 @@ | |||||
Subproject commit 4953cd4cc849afdfa02a6057b5a2011fb62e91a6 | |||||
Subproject commit 94b9877d65e46c9d8169ebc46f163d02e4d9dcf3 |
@@ -0,0 +1,6 @@ | |||||
{ | |||||
"files.trimTrailingWhitespace": true, | |||||
"files.trimFinalNewlines": true, | |||||
"files.insertFinalNewline": true, | |||||
"files.eol": "\n" | |||||
} |
@@ -1,34 +1,34 @@ | |||||
# Initialize CMake ################################################################################ | # Initialize CMake ################################################################################ | ||||
CMake_Minimum_Required ( VERSION 3.12.0 FATAL_ERROR ) | |||||
CMake_Minimum_Required ( VERSION 3.12.0 FATAL_ERROR ) | |||||
# Set CMAKE_BUILD_TYPE | # Set CMAKE_BUILD_TYPE | ||||
If ( NOT CMAKE_BUILD_TYPE ) | |||||
Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE ) | |||||
EndIf ( NOT CMAKE_BUILD_TYPE ) | |||||
Set_Property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel ) | |||||
If ( NOT CMAKE_BUILD_TYPE ) | |||||
Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE ) | |||||
EndIf ( NOT CMAKE_BUILD_TYPE ) | |||||
Set_Property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel ) | |||||
# Set CMAKE_MODULE_PATH | # Set CMAKE_MODULE_PATH | ||||
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
EndIf ( ) | |||||
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) | |||||
EndIf ( ) | |||||
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
EndIf ( ) | |||||
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/cmake" ) | |||||
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/cmake" ) | |||||
EndIf ( ) | |||||
# Project ######################################################################################### | # Project ######################################################################################### | ||||
Include ( CTest ) | |||||
Include ( GNUInstallDirs ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/helloworld-options.cmake ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/helloworld-const.cmake ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/helloworld-var.cmake ) | |||||
Project ( ${HELLOWORLD_PROJECT_NAME} | |||||
DESCRIPTION "${HELLOWORLD_PROJECT_DESCRIPTION}" | |||||
VERSION "${HELLOWORLD_VERSION}" ) | |||||
Include ( GNUInstallDirs ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/helloworld-options.cmake ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/helloworld-const.cmake ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/helloworld-var.cmake ) | |||||
Project ( ${HELLOWORLD_PROJECT_NAME} | |||||
DESCRIPTION "${HELLOWORLD_PROJECT_DESCRIPTION}" | |||||
VERSION "${HELLOWORLD_VERSION}" ) | |||||
Include ( CTest ) | |||||
# Subdirectories | # Subdirectories | ||||
Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) | |||||
Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/test ) | |||||
Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) | |||||
Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/test ) |
@@ -0,0 +1,3 @@ | |||||
# helloworld | |||||
Readme of the project. |
@@ -1,26 +1,26 @@ | |||||
# This file contains constant variables that are fixed to this project | # This file contains constant variables that are fixed to this project | ||||
# Version | # Version | ||||
Set ( HELLOWORLD_VERSION_MAJOR 1 ) | |||||
Set ( HELLOWORLD_VERSION_MINOR 0 ) | |||||
Set ( HELLOWORLD_VERSION_PATCH 0 ) | |||||
Set ( HELLOWORLD_VERSION_BUILD 0 ) | |||||
Set ( HELLOWORLD_VERSION_HASH "" ) | |||||
Set ( HELLOWORLD_VERSION_BEHIND 0 ) | |||||
Set ( HELLOWORLD_VERSION_DIRTY 0 ) | |||||
Set ( HELLOWORLD_VERSION_MAJOR 1 ) | |||||
Set ( HELLOWORLD_VERSION_MINOR 0 ) | |||||
Set ( HELLOWORLD_VERSION_PATCH 0 ) | |||||
Set ( HELLOWORLD_VERSION_BUILD 0 ) | |||||
Set ( HELLOWORLD_VERSION_HASH "" ) | |||||
Set ( HELLOWORLD_VERSION_BEHIND 0 ) | |||||
Set ( HELLOWORLD_VERSION_DIRTY 0 ) | |||||
# Names | # Names | ||||
Set ( HELLOWORLD_PROJECT_NAME "helloworld" ) | |||||
Set ( HELLOWORLD_PROJECT_DESCRIPTION "A simple hello world project" ) | |||||
Set ( HELLOWORLD_PROJECT_NAME "helloworld" ) | |||||
Set ( HELLOWORLD_PROJECT_DESCRIPTION "A simple hello world project" ) | |||||
# Include generated variables for further usage | # Include generated variables for further usage | ||||
Include ( ${CMAKE_CURRENT_LIST_DIR}/helloworld-var.cmake ) | |||||
Include ( ${CMAKE_CURRENT_LIST_DIR}/helloworld-var.cmake ) | |||||
# Install directories | # Install directories | ||||
Set ( HELLOWORLD_INSTALL_DIR_BIN "${CMAKE_INSTALL_BINDIR}" ) | |||||
Set ( HELLOWORLD_INSTALL_DIR_BIN "${CMAKE_INSTALL_BINDIR}" ) | |||||
# C Standard | # C Standard | ||||
Set ( CMAKE_C_STANDARD 11 ) | |||||
Set ( CMAKE_CXX_STANDARD 17 ) | |||||
Set ( CMAKE_C_STANDARD_REQUIRED ON ) | |||||
Set ( CMAKE_CXX_STANDARD_REQUIRED ON ) | |||||
Set ( CMAKE_C_STANDARD 11 ) | |||||
Set ( CMAKE_CXX_STANDARD 17 ) | |||||
Set ( CMAKE_C_STANDARD_REQUIRED ON ) | |||||
Set ( CMAKE_CXX_STANDARD_REQUIRED ON ) |
@@ -1,11 +1,11 @@ | |||||
# This file contains options that can be passed to the cmake command | # This file contains options that can be passed to the cmake command | ||||
Option ( HELLOWORLD_INSTALL_DEBUG | |||||
"Install the stripped debug informations of helloworld." | |||||
OFF ) | |||||
Option ( HELLOWORLD_NO_STRIP | |||||
"Do not strip debug symbols from helloworld binary." | |||||
OFF ) | |||||
Option ( HELLOWORLD_USE_GIT_VERSION | |||||
"Read the git tags to get the version of helloworld" | |||||
ON ) | |||||
Option ( HELLOWORLD_INSTALL_DEBUG | |||||
"Install the stripped debug informations of helloworld." | |||||
OFF ) | |||||
Option ( HELLOWORLD_NO_STRIP | |||||
"Do not strip debug symbols from helloworld binary." | |||||
OFF ) | |||||
Option ( HELLOWORLD_USE_GIT_VERSION | |||||
"Read the git tags to get the version of helloworld" | |||||
ON ) |
@@ -1,26 +1,32 @@ | |||||
# This file contains generated variables that are needed for the project | # This file contains generated variables that are needed for the project | ||||
# Git Version | # Git Version | ||||
If ( HELLOWORLD_USE_GIT_VERSION ) | |||||
Include ( git_helper OPTIONAL RESULT_VARIABLE HAS_GIT_HELPER ) | |||||
If ( HAS_GIT_HELPER ) | |||||
GitGetVersion ( ${CMAKE_CURRENT_LIST_DIR}/.. | |||||
HELLOWORLD_VERSION_MAJOR | |||||
HELLOWORLD_VERSION_MINOR | |||||
HELLOWORLD_VERSION_PATCH | |||||
HELLOWORLD_VERSION_BUILD | |||||
HELLOWORLD_VERSION_HASH | |||||
HELLOWORLD_VERSION_BEHIND | |||||
HELLOWORLD_VERSION_DIRTY ) | |||||
EndIf ( ) | |||||
EndIf ( ) | |||||
If ( HELLOWORLD_USE_GIT_VERSION ) | |||||
Include ( git_helper OPTIONAL RESULT_VARIABLE HAS_GIT_HELPER ) | |||||
If ( HAS_GIT_HELPER ) | |||||
GitGetVersion ( ${CMAKE_CURRENT_LIST_DIR}/.. | |||||
HELLOWORLD_VERSION_MAJOR | |||||
HELLOWORLD_VERSION_MINOR | |||||
HELLOWORLD_VERSION_PATCH | |||||
HELLOWORLD_VERSION_BUILD | |||||
HELLOWORLD_VERSION_HASH | |||||
HELLOWORLD_VERSION_BEHIND | |||||
HELLOWORLD_VERSION_DIRTY ) | |||||
EndIf ( ) | |||||
EndIf ( ) | |||||
# Strings | # Strings | ||||
Set ( HELLOWORLD_VERSION_SHORT "${HELLOWORLD_VERSION_MAJOR}.${HELLOWORLD_VERSION_MINOR}" ) | |||||
Set ( HELLOWORLD_VERSION "${HELLOWORLD_VERSION_SHORT}.${HELLOWORLD_VERSION_PATCH}.${HELLOWORLD_VERSION_BUILD}" ) | |||||
Set ( HELLOWORLD_VERSION_COMPLETE "${HELLOWORLD_VERSION}" ) | |||||
Set ( HELLOWORLD_NAME "${HELLOWORLD_PROJECT_NAME}-${HELLOWORLD_VERSION_SHORT}" ) | |||||
Set ( HELLOWORLD_OUTPUTNAME "${HELLOWORLD_PROJECT_NAME}" ) | |||||
If ( HELLOWORLD_VERSION_BEHIND ) | |||||
Set ( HELLOWORLD_VERSION_COMPLETE "${HELLOWORLD_VERSION_COMPLETE}+${HELLOWORLD_VERSION_BEHIND}" ) | |||||
EndIf ( ) | |||||
Set ( HELLOWORLD_VERSION_SHORT | |||||
"${HELLOWORLD_VERSION_MAJOR}.${HELLOWORLD_VERSION_MINOR}" ) | |||||
Set ( HELLOWORLD_VERSION | |||||
"${HELLOWORLD_VERSION_SHORT}.${HELLOWORLD_VERSION_PATCH}.${HELLOWORLD_VERSION_BUILD}" ) | |||||
Set ( HELLOWORLD_VERSION_COMPLETE | |||||
"${HELLOWORLD_VERSION}" ) | |||||
Set ( HELLOWORLD_NAME | |||||
"${HELLOWORLD_PROJECT_NAME}-${HELLOWORLD_VERSION_SHORT}" ) | |||||
Set ( HELLOWORLD_OUTPUTNAME | |||||
"${HELLOWORLD_PROJECT_NAME}" ) | |||||
If ( HELLOWORLD_VERSION_BEHIND ) | |||||
Set ( HELLOWORLD_VERSION_COMPLETE | |||||
"${HELLOWORLD_VERSION_COMPLETE}+${HELLOWORLD_VERSION_BEHIND}" ) | |||||
EndIf ( ) |
@@ -1,65 +1,73 @@ | |||||
# Initialize ###################################################################################### | # Initialize ###################################################################################### | ||||
Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | |||||
Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||||
Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) | |||||
Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | |||||
Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||||
Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) | |||||
Message ( WARNING "Please configure the dependencies of this project!" ) | |||||
Find_Package ( libhelloworld REQUIRED ) | |||||
Find_Package ( Sanitizers QUIET ) | |||||
Message ( WARNING "Please configure the dependencies of this project!" ) | |||||
Find_Package ( libhelloworld REQUIRED ) | |||||
# Object Library ################################################################################## | # Object Library ################################################################################## | ||||
Set ( HELLOWORLD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include ) | |||||
File ( GLOB_RECURSE HELLOWORLD_HEADER_FILES ${HELLOWORLD_INCLUDE_DIR}/*.h ) | |||||
File ( GLOB_RECURSE HELLOWORLD_INLINE_FILES ${HELLOWORLD_INCLUDE_DIR}/*.inl ) | |||||
File ( GLOB_RECURSE HELLOWORLD_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||||
List ( REMOVE_ITEM HELLOWORLD_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ) | |||||
Add_Library ( helloworld-objects | |||||
OBJECT | |||||
${HELLOWORLD_HEADER_FILES} | |||||
${HELLOWORLD_INLINE_FILES} | |||||
${HELLOWORLD_SOURCE_FILES} ) | |||||
Target_Include_Directories ( helloworld-objects | |||||
PUBLIC | |||||
$<BUILD_INTERFACE:${HELLOWORLD_INCLUDE_DIR}> | |||||
$<INSTALL_INTERFACE:${HELLOWORLD_INSTALL_DIR_INCLUDE}> ) | |||||
Target_Link_Libraries ( helloworld-objects | |||||
PUBLIC | |||||
libhelloworld-shared ) | |||||
Set ( HELLOWORLD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include ) | |||||
File ( GLOB_RECURSE HELLOWORLD_HEADER_FILES ${HELLOWORLD_INCLUDE_DIR}/*.h ) | |||||
File ( GLOB_RECURSE HELLOWORLD_INLINE_FILES ${HELLOWORLD_INCLUDE_DIR}/*.inl ) | |||||
File ( GLOB_RECURSE HELLOWORLD_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||||
List ( REMOVE_ITEM HELLOWORLD_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ) | |||||
Add_Library ( helloworld-objects | |||||
OBJECT | |||||
${HELLOWORLD_HEADER_FILES} | |||||
${HELLOWORLD_INLINE_FILES} | |||||
${HELLOWORLD_SOURCE_FILES} ) | |||||
Target_Include_Directories ( helloworld-objects | |||||
PUBLIC | |||||
$<BUILD_INTERFACE:${HELLOWORLD_INCLUDE_DIR}> | |||||
$<INSTALL_INTERFACE:${HELLOWORLD_INSTALL_DIR_INCLUDE}> ) | |||||
Target_Link_Libraries ( helloworld-objects | |||||
PUBLIC | |||||
libhelloworld-shared ) | |||||
# Executable ###################################################################################### | # Executable ###################################################################################### | ||||
Set ( HELLOWORLD_MAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ) | |||||
Add_Executable ( helloworld ${HELLOWORLD_MAIN_FILE} ) | |||||
Target_Link_Libraries ( helloworld | |||||
PUBLIC | |||||
helloworld-objects ) | |||||
Set ( HELLOWORLD_MAIN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp ) | |||||
Add_Executable ( helloworld ${HELLOWORLD_MAIN_FILE} ) | |||||
Target_Link_Libraries ( helloworld | |||||
PUBLIC | |||||
helloworld-objects ) | |||||
# Optimization #################################################################################### | # Optimization #################################################################################### | ||||
# sanitizers | |||||
If ( Sanitizers_FOUND ) | |||||
Add_Sanitizers ( helloworld-objects ) | |||||
Add_Sanitizers ( helloworld ) | |||||
EndIf ( ) | |||||
# pedantic | # pedantic | ||||
If ( HAS_PEDANTIC ) | |||||
Pedantic_Apply_Flags_Target ( helloworld-objects ALL ) | |||||
Pedantic_Apply_Flags_Target ( helloworld ALL ) | |||||
EndIf ( ) | |||||
If ( HAS_PEDANTIC ) | |||||
Pedantic_Apply_Flags_Target ( helloworld-objects ALL ) | |||||
Pedantic_Apply_Flags_Target ( helloworld ALL ) | |||||
EndIf ( ) | |||||
# cotire | # cotire | ||||
If ( HAS_COTIRE ) | |||||
Cotire ( helloworld-objects ) | |||||
Cotire ( helloworld ) | |||||
EndIf ( ) | |||||
If ( HAS_COTIRE ) | |||||
Cotire ( helloworld-objects ) | |||||
Cotire ( helloworld ) | |||||
EndIf ( ) | |||||
# Install ######################################################################################### | # Install ######################################################################################### | ||||
# Executable | # Executable | ||||
Install ( TARGETS helloworld | |||||
DESTINATION ${HELLOWORLD_INSTALL_DIR_BIN} ) | |||||
Install ( TARGETS helloworld | |||||
DESTINATION ${HELLOWORLD_INSTALL_DIR_BIN} ) | |||||
# Debug | # Debug | ||||
If ( HAS_STRIP_SYMBOLS AND NOT HELLOWORLD_NO_STRIP ) | |||||
Strip_Symbols ( helloworld HELLOWORLD_DBG_FILE ) | |||||
If ( HELLOWORLD_INSTALL_DEBUG ) | |||||
Install ( FILES ${HELLOWORLD_DBG_FILE} | |||||
DESTINATION ${HELLOWORLD_INSTALL_DIR_LIB} ) | |||||
EndIf ( ) | |||||
EndIf ( ) | |||||
If ( HAS_STRIP_SYMBOLS AND NOT HELLOWORLD_NO_STRIP ) | |||||
Strip_Symbols ( helloworld HELLOWORLD_DBG_FILE ) | |||||
If ( HELLOWORLD_INSTALL_DEBUG ) | |||||
Install ( FILES ${HELLOWORLD_DBG_FILE} | |||||
DESTINATION ${HELLOWORLD_INSTALL_DIR_LIB} ) | |||||
EndIf ( ) | |||||
EndIf ( ) |
@@ -1,52 +1,59 @@ | |||||
# Initialize ###################################################################################### | # Initialize ###################################################################################### | ||||
Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | |||||
Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||||
Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS ) | |||||
Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | |||||
Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||||
Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS ) | |||||
Find_Package ( Sanitizers QUIET ) | |||||
# Test ############################################################################################ | # Test ############################################################################################ | ||||
Find_Package ( GTest ) | |||||
If ( NOT "${GTest_FOUND}" ) | |||||
Return ( ) | |||||
EndIf ( ) | |||||
Find_Package ( GTest ) | |||||
If ( NOT "${GTest_FOUND}" ) | |||||
Return ( ) | |||||
EndIf ( ) | |||||
File ( GLOB_RECURSE HELLOWORLD_TEST_HEADER_FILES | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.h ) | |||||
File ( GLOB_RECURSE HELLOWORLD_TEST_INLINE_FILES | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.inl ) | |||||
File ( GLOB_RECURSE HELLOWORLD_TEST_SOURCE_FILES | |||||
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||||
File ( GLOB_RECURSE HELLOWORLD_TEST_HEADER_FILES | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.h ) | |||||
File ( GLOB_RECURSE HELLOWORLD_TEST_INLINE_FILES | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.inl ) | |||||
File ( GLOB_RECURSE HELLOWORLD_TEST_SOURCE_FILES | |||||
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||||
ForEach ( FILE IN LISTS HELLOWORLD_TEST_SOURCE_FILES ) | |||||
ForEach ( FILE IN LISTS HELLOWORLD_TEST_SOURCE_FILES ) | |||||
# add test | # add test | ||||
Get_Filename_Component ( TEST_DIR ${FILE} DIRECTORY ) | |||||
Get_Filename_Component ( TEST_NAME ${FILE} NAME_WE ) | |||||
Set ( TEST_NAME "${TEST_DIR}/${TEST_NAME}" ) | |||||
String ( REPLACE "\\" "-" TEST_NAME "${TEST_NAME}" ) | |||||
String ( REPLACE "/" "-" TEST_NAME "${TEST_NAME}" ) | |||||
String ( REPLACE "_" "-" TEST_NAME "${TEST_NAME}" ) | |||||
Set ( TEST_NAME "test-${TEST_NAME}" ) | |||||
Add_Executable ( ${TEST_NAME} | |||||
EXCLUDE_FROM_ALL | |||||
${HELLOWORLD_TEST_HEADER_FILES} | |||||
${HELLOWORLD_TEST_INLINE_FILES} | |||||
${FILE} ) | |||||
Target_Link_Libraries ( ${TEST_NAME} | |||||
PUBLIC | |||||
helloworld-objects | |||||
GTest::Main ) | |||||
Get_Filename_Component ( TEST_DIR ${FILE} DIRECTORY ) | |||||
Get_Filename_Component ( TEST_NAME ${FILE} NAME_WE ) | |||||
Set ( TEST_NAME "${TEST_DIR}/${TEST_NAME}" ) | |||||
String ( REPLACE "\\" "-" TEST_NAME "${TEST_NAME}" ) | |||||
String ( REPLACE "/" "-" TEST_NAME "${TEST_NAME}" ) | |||||
String ( REPLACE "_" "-" TEST_NAME "${TEST_NAME}" ) | |||||
Set ( TEST_NAME "test-${TEST_NAME}" ) | |||||
Add_Executable ( ${TEST_NAME} | |||||
EXCLUDE_FROM_ALL | |||||
${HELLOWORLD_TEST_HEADER_FILES} | |||||
${HELLOWORLD_TEST_INLINE_FILES} | |||||
${FILE} ) | |||||
Target_Link_Libraries ( ${TEST_NAME} | |||||
PUBLIC | |||||
helloworld-objects | |||||
GTest::Main ) | |||||
# Sanitizers | |||||
If ( Sanitizers_FOUND ) | |||||
Add_Sanitizers ( ${TEST_NAME} ) | |||||
EndIf ( ) | |||||
# pedantic | # pedantic | ||||
If ( HAS_PEDANTIC ) | |||||
Pedantic_Apply_Flags_Target ( ${TEST_NAME} ALL ) | |||||
EndIf ( ) | |||||
If ( HAS_PEDANTIC ) | |||||
Pedantic_Apply_Flags_Target ( ${TEST_NAME} ALL ) | |||||
EndIf ( ) | |||||
# test | # test | ||||
If ( HAS_CMAKE_TESTS ) | |||||
Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} ) | |||||
Else ( ) | |||||
Add_Test ( NAME ${TEST_NAME} COMMAND ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) | |||||
EndIf ( ) | |||||
EndForEach ( ) | |||||
If ( HAS_CMAKE_TESTS ) | |||||
Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} ) | |||||
Else ( ) | |||||
Add_Test ( NAME ${TEST_NAME} COMMAND ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) | |||||
EndIf ( ) | |||||
EndForEach ( ) |
@@ -0,0 +1,6 @@ | |||||
{ | |||||
"files.trimTrailingWhitespace": true, | |||||
"files.trimFinalNewlines": true, | |||||
"files.insertFinalNewline": true, | |||||
"files.eol": "\n" | |||||
} |
@@ -1,63 +1,63 @@ | |||||
# Initialize CMake ################################################################################ | # Initialize CMake ################################################################################ | ||||
CMake_Minimum_Required ( VERSION 3.12.0 FATAL_ERROR ) | |||||
CMake_Minimum_Required ( VERSION 3.12.0 FATAL_ERROR ) | |||||
# Set CMAKE_BUILD_TYPE | # Set CMAKE_BUILD_TYPE | ||||
If ( NOT CMAKE_BUILD_TYPE ) | |||||
Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE ) | |||||
EndIf ( NOT CMAKE_BUILD_TYPE ) | |||||
Set_Property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel ) | |||||
If ( NOT CMAKE_BUILD_TYPE ) | |||||
Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE ) | |||||
EndIf ( NOT CMAKE_BUILD_TYPE ) | |||||
Set_Property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel ) | |||||
# Set CMAKE_MODULE_PATH | # Set CMAKE_MODULE_PATH | ||||
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
EndIf ( ) | |||||
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) | |||||
EndIf ( ) | |||||
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
EndIf ( ) | |||||
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/cmake" ) | |||||
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/cmake" ) | |||||
EndIf ( ) | |||||
# Project ######################################################################################### | # Project ######################################################################################### | ||||
Include ( CTest ) | |||||
Include ( GNUInstallDirs ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libhelloworld-options.cmake ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libhelloworld-const.cmake ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libhelloworld-var.cmake ) | |||||
Project ( ${LIBHELLOWORLD_PROJECT_NAME} | |||||
DESCRIPTION "${LIBHELLOWORLD_PROJECT_DESCRIPTION}" | |||||
VERSION "${LIBHELLOWORLD_VERSION}" ) | |||||
Include ( GNUInstallDirs ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libhelloworld-options.cmake ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libhelloworld-const.cmake ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libhelloworld-var.cmake ) | |||||
Project ( ${LIBHELLOWORLD_PROJECT_NAME} | |||||
DESCRIPTION "${LIBHELLOWORLD_PROJECT_DESCRIPTION}" | |||||
VERSION "${LIBHELLOWORLD_VERSION}" ) | |||||
Include ( CTest ) | |||||
# Subdirectories | # Subdirectories | ||||
Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) | |||||
Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/test ) | |||||
Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) | |||||
Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/test ) | |||||
# Install | # Install | ||||
If ( NOT LIBHELLOWORLD_HAS_EXPORT | |||||
OR NOT LIBHELLOWORLD_INSTALL_PACKAGE ) | |||||
Return ( ) | |||||
EndIf ( ) | |||||
Include ( CMakePackageConfigHelpers ) | |||||
Write_Basic_Package_Version_File ( "${CMAKE_CURRENT_BINARY_DIR}/cmake/libhelloworld-config-version.cmake" | |||||
VERSION ${LIBHELLOWORLD_VERSION} | |||||
COMPATIBILITY AnyNewerVersion ) | |||||
Configure_File ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/libhelloworld-config.cmake" | |||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/libhelloworld-config.cmake" | |||||
@ONLY ) | |||||
Set ( ConfigPackageLocation "${LIBHELLOWORLD_INSTALL_DIR_SHARE}/cmake" ) | |||||
Install ( EXPORT | |||||
libhelloworld | |||||
NAMESPACE | |||||
libhelloworld:: | |||||
DESTINATION | |||||
${ConfigPackageLocation} ) | |||||
Install ( FILES | |||||
If ( NOT LIBHELLOWORLD_HAS_EXPORT | |||||
OR NOT LIBHELLOWORLD_INSTALL_PACKAGE ) | |||||
Return ( ) | |||||
EndIf ( ) | |||||
Include ( CMakePackageConfigHelpers ) | |||||
Write_Basic_Package_Version_File ( "${CMAKE_CURRENT_BINARY_DIR}/cmake/libhelloworld-config-version.cmake" | |||||
VERSION ${LIBHELLOWORLD_VERSION} | |||||
COMPATIBILITY AnyNewerVersion ) | |||||
Configure_File ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/libhelloworld-config.cmake" | |||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/libhelloworld-config.cmake" | "${CMAKE_CURRENT_BINARY_DIR}/cmake/libhelloworld-config.cmake" | ||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/libhelloworld-config-version.cmake" | |||||
DESTINATION | |||||
${ConfigPackageLocation} | |||||
COMPONENT | |||||
Devel ) | |||||
@ONLY ) | |||||
Set ( ConfigPackageLocation "${LIBHELLOWORLD_INSTALL_DIR_SHARE}/cmake" ) | |||||
Install ( EXPORT | |||||
libhelloworld | |||||
NAMESPACE | |||||
libhelloworld:: | |||||
DESTINATION | |||||
${ConfigPackageLocation} ) | |||||
Install ( FILES | |||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/libhelloworld-config.cmake" | |||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/libhelloworld-config-version.cmake" | |||||
DESTINATION | |||||
${ConfigPackageLocation} | |||||
COMPONENT | |||||
Devel ) |
@@ -0,0 +1,3 @@ | |||||
# libhelloworld | |||||
Readme of the project. |
@@ -1,28 +1,28 @@ | |||||
# This file contains constant variables that are fixed to this project | # This file contains constant variables that are fixed to this project | ||||
# Version | # Version | ||||
Set ( LIBHELLOWORLD_VERSION_MAJOR 1 ) | |||||
Set ( LIBHELLOWORLD_VERSION_MINOR 0 ) | |||||
Set ( LIBHELLOWORLD_VERSION_PATCH 0 ) | |||||
Set ( LIBHELLOWORLD_VERSION_BUILD 0 ) | |||||
Set ( LIBHELLOWORLD_VERSION_HASH "" ) | |||||
Set ( LIBHELLOWORLD_VERSION_BEHIND 0 ) | |||||
Set ( LIBHELLOWORLD_VERSION_DIRTY 0 ) | |||||
Set ( LIBHELLOWORLD_VERSION_MAJOR 1 ) | |||||
Set ( LIBHELLOWORLD_VERSION_MINOR 0 ) | |||||
Set ( LIBHELLOWORLD_VERSION_PATCH 0 ) | |||||
Set ( LIBHELLOWORLD_VERSION_BUILD 0 ) | |||||
Set ( LIBHELLOWORLD_VERSION_HASH "" ) | |||||
Set ( LIBHELLOWORLD_VERSION_BEHIND 0 ) | |||||
Set ( LIBHELLOWORLD_VERSION_DIRTY 0 ) | |||||
# Names | # Names | ||||
Set ( LIBHELLOWORLD_PROJECT_NAME "libhelloworld" ) | |||||
Set ( LIBHELLOWORLD_PROJECT_DESCRIPTION "A simple hello world library" ) | |||||
Set ( LIBHELLOWORLD_PROJECT_NAME "libhelloworld" ) | |||||
Set ( LIBHELLOWORLD_PROJECT_DESCRIPTION "A simple hello world library" ) | |||||
# Include generated variables for further usage | # Include generated variables for further usage | ||||
Include ( ${CMAKE_CURRENT_LIST_DIR}/libhelloworld-var.cmake ) | |||||
Include ( ${CMAKE_CURRENT_LIST_DIR}/libhelloworld-var.cmake ) | |||||
# Install directories | # Install directories | ||||
Set ( LIBHELLOWORLD_INSTALL_DIR_INCLUDE "${CMAKE_INSTALL_INCLUDEDIR}/${LIBHELLOWORLD_NAME}" ) | |||||
Set ( LIBHELLOWORLD_INSTALL_DIR_LIB "${CMAKE_INSTALL_LIBDIR}" ) | |||||
Set ( LIBHELLOWORLD_INSTALL_DIR_SHARE "${CMAKE_INSTALL_DATAROOTDIR}/${LIBHELLOWORLD_NAME}" ) | |||||
Set ( LIBHELLOWORLD_INSTALL_DIR_INCLUDE "${CMAKE_INSTALL_INCLUDEDIR}/${LIBHELLOWORLD_NAME}" ) | |||||
Set ( LIBHELLOWORLD_INSTALL_DIR_LIB "${CMAKE_INSTALL_LIBDIR}" ) | |||||
Set ( LIBHELLOWORLD_INSTALL_DIR_SHARE "${CMAKE_INSTALL_DATAROOTDIR}/${LIBHELLOWORLD_NAME}" ) | |||||
# C Standard | # C Standard | ||||
Set ( CMAKE_C_STANDARD 11 ) | |||||
Set ( CMAKE_CXX_STANDARD 17 ) | |||||
Set ( CMAKE_C_STANDARD_REQUIRED ON ) | |||||
Set ( CMAKE_CXX_STANDARD_REQUIRED ON ) | |||||
Set ( CMAKE_C_STANDARD 11 ) | |||||
Set ( CMAKE_CXX_STANDARD 17 ) | |||||
Set ( CMAKE_C_STANDARD_REQUIRED ON ) | |||||
Set ( CMAKE_CXX_STANDARD_REQUIRED ON ) |
@@ -1,23 +1,23 @@ | |||||
# This file contains options that can be passed to the cmake command | # This file contains options that can be passed to the cmake command | ||||
Option ( LIBHELLOWORLD_INSTALL_HEADER | |||||
"Install headers of libhelloworld." | |||||
ON ) | |||||
Option ( LIBHELLOWORLD_INSTALL_STATIC | |||||
"Install static library of libhelloworld." | |||||
ON ) | |||||
Option ( LIBHELLOWORLD_INSTALL_SHARED | |||||
"Install shared library of libhelloworld." | |||||
ON ) | |||||
Option ( LIBHELLOWORLD_INSTALL_DEBUG | |||||
"Install the stripped debug informations of libhelloworld." | |||||
OFF ) | |||||
Option ( LIBHELLOWORLD_INSTALL_PACKAGE | |||||
"Install the cmake package of libhelloworld." | |||||
ON ) | |||||
Option ( LIBHELLOWORLD_NO_STRIP | |||||
"Do not strip debug symbols from binary." | |||||
OFF ) | |||||
Option ( LIBHELLOWORLD_USE_GIT_VERSION | |||||
"Read the git tags to get the version of libhelloworld" | |||||
ON ) | |||||
Option ( LIBHELLOWORLD_INSTALL_HEADER | |||||
"Install headers of libhelloworld." | |||||
ON ) | |||||
Option ( LIBHELLOWORLD_INSTALL_STATIC | |||||
"Install static library of libhelloworld." | |||||
ON ) | |||||
Option ( LIBHELLOWORLD_INSTALL_SHARED | |||||
"Install shared library of libhelloworld." | |||||
ON ) | |||||
Option ( LIBHELLOWORLD_INSTALL_DEBUG | |||||
"Install the stripped debug informations of libhelloworld." | |||||
OFF ) | |||||
Option ( LIBHELLOWORLD_INSTALL_PACKAGE | |||||
"Install the cmake package of libhelloworld." | |||||
ON ) | |||||
Option ( LIBHELLOWORLD_NO_STRIP | |||||
"Do not strip debug symbols from binary." | |||||
OFF ) | |||||
Option ( LIBHELLOWORLD_USE_GIT_VERSION | |||||
"Read the git tags to get the version of libhelloworld" | |||||
ON ) |
@@ -1,26 +1,32 @@ | |||||
# This file contains generated variables that are needed for the project | # This file contains generated variables that are needed for the project | ||||
# Git Version | # Git Version | ||||
If ( LIBHELLOWORLD_USE_GIT_VERSION ) | |||||
Include ( git_helper OPTIONAL RESULT_VARIABLE HAS_GIT_HELPER ) | |||||
If ( HAS_GIT_HELPER ) | |||||
GitGetVersion ( ${CMAKE_CURRENT_LIST_DIR}/.. | |||||
LIBHELLOWORLD_VERSION_MAJOR | |||||
LIBHELLOWORLD_VERSION_MINOR | |||||
LIBHELLOWORLD_VERSION_PATCH | |||||
LIBHELLOWORLD_VERSION_BUILD | |||||
LIBHELLOWORLD_VERSION_HASH | |||||
LIBHELLOWORLD_VERSION_BEHIND | |||||
LIBHELLOWORLD_VERSION_DIRTY ) | |||||
EndIf ( ) | |||||
EndIf ( ) | |||||
If ( LIBHELLOWORLD_USE_GIT_VERSION ) | |||||
Include ( git_helper OPTIONAL RESULT_VARIABLE HAS_GIT_HELPER ) | |||||
If ( HAS_GIT_HELPER ) | |||||
GitGetVersion ( ${CMAKE_CURRENT_LIST_DIR}/.. | |||||
LIBHELLOWORLD_VERSION_MAJOR | |||||
LIBHELLOWORLD_VERSION_MINOR | |||||
LIBHELLOWORLD_VERSION_PATCH | |||||
LIBHELLOWORLD_VERSION_BUILD | |||||
LIBHELLOWORLD_VERSION_HASH | |||||
LIBHELLOWORLD_VERSION_BEHIND | |||||
LIBHELLOWORLD_VERSION_DIRTY ) | |||||
EndIf ( ) | |||||
EndIf ( ) | |||||
# Strings | # Strings | ||||
Set ( LIBHELLOWORLD_VERSION_SHORT "${LIBHELLOWORLD_VERSION_MAJOR}.${LIBHELLOWORLD_VERSION_MINOR}" ) | |||||
Set ( LIBHELLOWORLD_VERSION "${LIBHELLOWORLD_VERSION_SHORT}.${LIBHELLOWORLD_VERSION_PATCH}.${LIBHELLOWORLD_VERSION_BUILD}" ) | |||||
Set ( LIBHELLOWORLD_VERSION_COMPLETE "${LIBHELLOWORLD_VERSION}" ) | |||||
Set ( LIBHELLOWORLD_NAME "${LIBHELLOWORLD_PROJECT_NAME}-${LIBHELLOWORLD_VERSION_SHORT}" ) | |||||
Set ( LIBHELLOWORLD_OUTPUTNAME "${LIBHELLOWORLD_PROJECT_NAME}" ) | |||||
If ( LIBHELLOWORLD_VERSION_BEHIND ) | |||||
Set ( LIBHELLOWORLD_VERSION_COMPLETE "${LIBHELLOWORLD_VERSION_COMPLETE}+${LIBHELLOWORLD_VERSION_BEHIND}" ) | |||||
EndIf ( ) | |||||
Set ( LIBHELLOWORLD_VERSION_SHORT | |||||
"${LIBHELLOWORLD_VERSION_MAJOR}.${LIBHELLOWORLD_VERSION_MINOR}" ) | |||||
Set ( LIBHELLOWORLD_VERSION | |||||
"${LIBHELLOWORLD_VERSION_SHORT}.${LIBHELLOWORLD_VERSION_PATCH}.${LIBHELLOWORLD_VERSION_BUILD}" ) | |||||
Set ( LIBHELLOWORLD_VERSION_COMPLETE | |||||
"${LIBHELLOWORLD_VERSION}" ) | |||||
Set ( LIBHELLOWORLD_NAME | |||||
"${LIBHELLOWORLD_PROJECT_NAME}-${LIBHELLOWORLD_VERSION_SHORT}" ) | |||||
Set ( LIBHELLOWORLD_OUTPUTNAME | |||||
"${LIBHELLOWORLD_PROJECT_NAME}" ) | |||||
If ( LIBHELLOWORLD_VERSION_BEHIND ) | |||||
Set ( LIBHELLOWORLD_VERSION_COMPLETE | |||||
"${LIBHELLOWORLD_VERSION_COMPLETE}+${LIBHELLOWORLD_VERSION_BEHIND}" ) | |||||
EndIf ( ) |
@@ -1,100 +1,107 @@ | |||||
# Initialize ###################################################################################### | # Initialize ###################################################################################### | ||||
Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | |||||
Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||||
Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) | |||||
Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | |||||
Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||||
Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) | |||||
Find_Package ( Sanitizers QUIET ) | |||||
# Object Library ################################################################################## | # Object Library ################################################################################## | ||||
Set ( CMAKE_POSITION_INDEPENDENT_CODE ON ) | |||||
Set ( LIBHELLOWORLD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include ) | |||||
File ( GLOB_RECURSE LIBHELLOWORLD_HEADER_FILES ${LIBHELLOWORLD_INCLUDE_DIR}/*.h ) | |||||
File ( GLOB_RECURSE LIBHELLOWORLD_INLINE_FILES ${LIBHELLOWORLD_INCLUDE_DIR}/*.inl ) | |||||
File ( GLOB_RECURSE LIBHELLOWORLD_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||||
Add_Library ( libhelloworld-objects | |||||
OBJECT | |||||
${LIBHELLOWORLD_HEADER_FILES} | |||||
${LIBHELLOWORLD_INLINE_FILES} | |||||
${LIBHELLOWORLD_SOURCE_FILES} ) | |||||
Target_Include_Directories ( libhelloworld-objects | |||||
PUBLIC | |||||
$<BUILD_INTERFACE:${LIBHELLOWORLD_INCLUDE_DIR}> | |||||
$<INSTALL_INTERFACE:${LIBHELLOWORLD_INSTALL_DIR_INCLUDE}> ) | |||||
Set ( CMAKE_POSITION_INDEPENDENT_CODE ON ) | |||||
Set ( LIBHELLOWORLD_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include ) | |||||
File ( GLOB_RECURSE LIBHELLOWORLD_HEADER_FILES ${LIBHELLOWORLD_INCLUDE_DIR}/*.h ) | |||||
File ( GLOB_RECURSE LIBHELLOWORLD_INLINE_FILES ${LIBHELLOWORLD_INCLUDE_DIR}/*.inl ) | |||||
File ( GLOB_RECURSE LIBHELLOWORLD_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||||
Add_Library ( libhelloworld-objects | |||||
OBJECT | |||||
${LIBHELLOWORLD_HEADER_FILES} | |||||
${LIBHELLOWORLD_INLINE_FILES} | |||||
${LIBHELLOWORLD_SOURCE_FILES} ) | |||||
Target_Include_Directories ( libhelloworld-objects | |||||
PUBLIC | |||||
$<BUILD_INTERFACE:${LIBHELLOWORLD_INCLUDE_DIR}> | |||||
$<INSTALL_INTERFACE:${LIBHELLOWORLD_INSTALL_DIR_INCLUDE}> ) | |||||
# Static Library ################################################################################## | # Static Library ################################################################################## | ||||
Add_Library ( libhelloworld-static STATIC $<TARGET_OBJECTS:libhelloworld-objects> ) | |||||
Set_Target_Properties ( libhelloworld-static | |||||
PROPERTIES | |||||
OUTPUT_NAME "${LIBHELLOWORLD_OUTPUTNAME}" | |||||
VERSION ${LIBHELLOWORLD_VERSION} ) | |||||
Target_Include_Directories ( libhelloworld-static | |||||
PUBLIC | |||||
$<BUILD_INTERFACE:${LIBHELLOWORLD_INCLUDE_DIR}> | |||||
$<INSTALL_INTERFACE:${LIBHELLOWORLD_INSTALL_DIR_INCLUDE}> ) | |||||
Add_Library ( libhelloworld-static STATIC $<TARGET_OBJECTS:libhelloworld-objects> ) | |||||
Set_Target_Properties ( libhelloworld-static | |||||
PROPERTIES | |||||
OUTPUT_NAME "${LIBHELLOWORLD_OUTPUTNAME}" | |||||
VERSION ${LIBHELLOWORLD_VERSION} ) | |||||
Target_Include_Directories ( libhelloworld-static | |||||
PUBLIC | |||||
$<BUILD_INTERFACE:${LIBHELLOWORLD_INCLUDE_DIR}> | |||||
$<INSTALL_INTERFACE:${LIBHELLOWORLD_INSTALL_DIR_INCLUDE}> ) | |||||
# Shared Library ################################################################################## | # Shared Library ################################################################################## | ||||
Add_Library ( libhelloworld-shared SHARED $<TARGET_OBJECTS:libhelloworld-objects> ) | |||||
Set_Target_Properties ( libhelloworld-shared | |||||
PROPERTIES | |||||
OUTPUT_NAME "${LIBHELLOWORLD_OUTPUTNAME}" | |||||
VERSION ${LIBHELLOWORLD_VERSION} | |||||
SOVERSION ${LIBHELLOWORLD_VERSION_SHORT} ) | |||||
Target_Include_Directories ( libhelloworld-shared | |||||
PUBLIC | |||||
$<BUILD_INTERFACE:${LIBHELLOWORLD_INCLUDE_DIR}> | |||||
$<INSTALL_INTERFACE:${LIBHELLOWORLD_INSTALL_DIR_INCLUDE}> ) | |||||
Add_Library ( libhelloworld-shared SHARED $<TARGET_OBJECTS:libhelloworld-objects> ) | |||||
Set_Target_Properties ( libhelloworld-shared | |||||
PROPERTIES | |||||
OUTPUT_NAME "${LIBHELLOWORLD_OUTPUTNAME}" | |||||
VERSION ${LIBHELLOWORLD_VERSION} | |||||
SOVERSION ${LIBHELLOWORLD_VERSION_SHORT} ) | |||||
Target_Include_Directories ( libhelloworld-shared | |||||
PUBLIC | |||||
$<BUILD_INTERFACE:${LIBHELLOWORLD_INCLUDE_DIR}> | |||||
$<INSTALL_INTERFACE:${LIBHELLOWORLD_INSTALL_DIR_INCLUDE}> ) | |||||
# Optimization #################################################################################### | # Optimization #################################################################################### | ||||
# sanitizers | |||||
If ( Sanitizers_FOUND ) | |||||
Add_Sanitizers ( libhelloworld-objects ) | |||||
EndIf ( ) | |||||
# pedantic | # pedantic | ||||
If ( HAS_PEDANTIC ) | |||||
Pedantic_Apply_Flags_Target ( libhelloworld-objects ALL ) | |||||
Pedantic_Apply_Flags_Target ( libhelloworld-static ALL ) | |||||
Pedantic_Apply_Flags_Target ( libhelloworld-shared ALL ) | |||||
EndIf ( ) | |||||
If ( HAS_PEDANTIC ) | |||||
Pedantic_Apply_Flags_Target ( libhelloworld-objects ALL ) | |||||
Pedantic_Apply_Flags_Target ( libhelloworld-static ALL ) | |||||
Pedantic_Apply_Flags_Target ( libhelloworld-shared ALL ) | |||||
EndIf ( ) | |||||
# cotire | # cotire | ||||
If ( HAS_COTIRE ) | |||||
Cotire ( libhelloworld-objects ) | |||||
Cotire ( libhelloworld-static ) | |||||
Cotire ( libhelloworld-shared ) | |||||
EndIf ( ) | |||||
If ( HAS_COTIRE ) | |||||
Cotire ( libhelloworld-objects ) | |||||
Cotire ( libhelloworld-static ) | |||||
Cotire ( libhelloworld-shared ) | |||||
EndIf ( ) | |||||
# Install ######################################################################################### | # Install ######################################################################################### | ||||
Set ( LIBHELLOWORLD_HAS_EXPORT False PARENT_SCOPE ) | |||||
Set ( LIBHELLOWORLD_HAS_EXPORT False PARENT_SCOPE ) | |||||
# Header | # Header | ||||
If ( LIBHELLOWORLD_INSTALL_HEADER ) | |||||
Install ( FILES ${LIBHELLOWORLD_INCLUDE_DIR}/libhelloworld.h | |||||
DESTINATION ${LIBHELLOWORLD_INSTALL_DIR_INCLUDE} ) | |||||
Install ( DIRECTORY ${LIBHELLOWORLD_INCLUDE_DIR}/libhelloworld | |||||
DESTINATION ${LIBHELLOWORLD_INSTALL_DIR_INCLUDE} ) | |||||
EndIf ( ) | |||||
If ( LIBHELLOWORLD_INSTALL_HEADER ) | |||||
Install ( FILES ${LIBHELLOWORLD_INCLUDE_DIR}/libhelloworld.h | |||||
DESTINATION ${LIBHELLOWORLD_INSTALL_DIR_INCLUDE} ) | |||||
Install ( DIRECTORY ${LIBHELLOWORLD_INCLUDE_DIR}/libhelloworld | |||||
DESTINATION ${LIBHELLOWORLD_INSTALL_DIR_INCLUDE} ) | |||||
EndIf ( ) | |||||
# Static | # Static | ||||
If ( LIBHELLOWORLD_INSTALL_STATIC ) | |||||
Set ( LIBHELLOWORLD_HAS_EXPORT True PARENT_SCOPE ) | |||||
Install ( TARGETS libhelloworld-static | |||||
EXPORT libhelloworld | |||||
DESTINATION ${LIBHELLOWORLD_INSTALL_DIR_LIB} ) | |||||
EndIf ( ) | |||||
If ( LIBHELLOWORLD_INSTALL_STATIC ) | |||||
Set ( LIBHELLOWORLD_HAS_EXPORT True PARENT_SCOPE ) | |||||
Install ( TARGETS libhelloworld-static | |||||
EXPORT libhelloworld | |||||
DESTINATION ${LIBHELLOWORLD_INSTALL_DIR_LIB} ) | |||||
EndIf ( ) | |||||
# Shared | # Shared | ||||
If ( LIBHELLOWORLD_INSTALL_SHARED ) | |||||
Set ( LIBHELLOWORLD_HAS_EXPORT True PARENT_SCOPE ) | |||||
Install ( TARGETS libhelloworld-shared | |||||
EXPORT libhelloworld | |||||
DESTINATION ${LIBHELLOWORLD_INSTALL_DIR_LIB} ) | |||||
EndIf ( ) | |||||
If ( LIBHELLOWORLD_INSTALL_SHARED ) | |||||
Set ( LIBHELLOWORLD_HAS_EXPORT True PARENT_SCOPE ) | |||||
Install ( TARGETS libhelloworld-shared | |||||
EXPORT libhelloworld | |||||
DESTINATION ${LIBHELLOWORLD_INSTALL_DIR_LIB} ) | |||||
EndIf ( ) | |||||
# Debug | # Debug | ||||
If ( HAS_STRIP_SYMBOLS AND NOT LIBHELLOWORLD_NO_STRIP ) | |||||
Strip_Symbols ( libhelloworld-shared LIBHELLOWORLD_DBG_FILE ) | |||||
If ( LIBHELLOWORLD_INSTALL_DEBUG ) | |||||
Install ( FILES ${LIBHELLOWORLD_DBG_FILE} | |||||
DESTINATION ${LIBHELLOWORLD_INSTALL_DIR_LIB} ) | |||||
EndIf ( ) | |||||
EndIf ( ) | |||||
If ( HAS_STRIP_SYMBOLS AND NOT LIBHELLOWORLD_NO_STRIP ) | |||||
Strip_Symbols ( libhelloworld-shared LIBHELLOWORLD_DBG_FILE ) | |||||
If ( LIBHELLOWORLD_INSTALL_DEBUG ) | |||||
Install ( FILES ${LIBHELLOWORLD_DBG_FILE} | |||||
DESTINATION ${LIBHELLOWORLD_INSTALL_DIR_LIB} ) | |||||
EndIf ( ) | |||||
EndIf ( ) |
@@ -1,52 +1,59 @@ | |||||
# Initialize ###################################################################################### | # Initialize ###################################################################################### | ||||
Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | |||||
Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||||
Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS ) | |||||
Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | |||||
Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||||
Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS ) | |||||
Find_Package ( Sanitizers QUIET ) | |||||
# Test ############################################################################################ | # Test ############################################################################################ | ||||
Find_Package ( GTest ) | |||||
If ( NOT "${GTest_FOUND}" ) | |||||
Return ( ) | |||||
EndIf ( ) | |||||
Find_Package ( GTest ) | |||||
If ( NOT "${GTest_FOUND}" ) | |||||
Return ( ) | |||||
EndIf ( ) | |||||
File ( GLOB_RECURSE LIBHELLOWORLD_TEST_HEADER_FILES | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.h ) | |||||
File ( GLOB_RECURSE LIBHELLOWORLD_TEST_INLINE_FILES | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.inl ) | |||||
File ( GLOB_RECURSE LIBHELLOWORLD_TEST_SOURCE_FILES | |||||
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||||
File ( GLOB_RECURSE LIBHELLOWORLD_TEST_HEADER_FILES | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.h ) | |||||
File ( GLOB_RECURSE LIBHELLOWORLD_TEST_INLINE_FILES | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.inl ) | |||||
File ( GLOB_RECURSE LIBHELLOWORLD_TEST_SOURCE_FILES | |||||
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||||
ForEach ( FILE IN LISTS LIBHELLOWORLD_TEST_SOURCE_FILES ) | |||||
ForEach ( FILE IN LISTS LIBHELLOWORLD_TEST_SOURCE_FILES ) | |||||
# add test | # add test | ||||
Get_Filename_Component ( TEST_DIR ${FILE} DIRECTORY ) | |||||
Get_Filename_Component ( TEST_NAME ${FILE} NAME_WE ) | |||||
Set ( TEST_NAME "${TEST_DIR}/${TEST_NAME}" ) | |||||
String ( REPLACE "\\" "-" TEST_NAME "${TEST_NAME}" ) | |||||
String ( REPLACE "/" "-" TEST_NAME "${TEST_NAME}" ) | |||||
String ( REPLACE "_" "-" TEST_NAME "${TEST_NAME}" ) | |||||
Set ( TEST_NAME "test-${TEST_NAME}" ) | |||||
Add_Executable ( ${TEST_NAME} | |||||
EXCLUDE_FROM_ALL | |||||
${LIBHELLOWORLD_TEST_HEADER_FILES} | |||||
${LIBHELLOWORLD_TEST_INLINE_FILES} | |||||
${FILE} ) | |||||
Target_Link_Libraries ( ${TEST_NAME} | |||||
PUBLIC | |||||
libhelloworld-objects | |||||
GTest::Main ) | |||||
Get_Filename_Component ( TEST_DIR ${FILE} DIRECTORY ) | |||||
Get_Filename_Component ( TEST_NAME ${FILE} NAME_WE ) | |||||
Set ( TEST_NAME "${TEST_DIR}/${TEST_NAME}" ) | |||||
String ( REPLACE "\\" "-" TEST_NAME "${TEST_NAME}" ) | |||||
String ( REPLACE "/" "-" TEST_NAME "${TEST_NAME}" ) | |||||
String ( REPLACE "_" "-" TEST_NAME "${TEST_NAME}" ) | |||||
Set ( TEST_NAME "test-${TEST_NAME}" ) | |||||
Add_Executable ( ${TEST_NAME} | |||||
EXCLUDE_FROM_ALL | |||||
${LIBHELLOWORLD_TEST_HEADER_FILES} | |||||
${LIBHELLOWORLD_TEST_INLINE_FILES} | |||||
${FILE} ) | |||||
Target_Link_Libraries ( ${TEST_NAME} | |||||
PUBLIC | |||||
libhelloworld-objects | |||||
GTest::Main ) | |||||
# Sanitizers | |||||
If ( Sanitizers_FOUND ) | |||||
Add_Sanitizers ( ${TEST_NAME} ) | |||||
EndIf ( ) | |||||
# pedantic | # pedantic | ||||
If ( HAS_PEDANTIC ) | |||||
Pedantic_Apply_Flags_Target ( ${TEST_NAME} ALL ) | |||||
EndIf ( ) | |||||
If ( HAS_PEDANTIC ) | |||||
Pedantic_Apply_Flags_Target ( ${TEST_NAME} ALL ) | |||||
EndIf ( ) | |||||
# test | # test | ||||
If ( HAS_CMAKE_TESTS ) | |||||
Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} ) | |||||
Else ( ) | |||||
Add_Test ( NAME ${TEST_NAME} COMMAND ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) | |||||
EndIf ( ) | |||||
EndForEach ( ) | |||||
If ( HAS_CMAKE_TESTS ) | |||||
Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} ) | |||||
Else ( ) | |||||
Add_Test ( NAME ${TEST_NAME} COMMAND ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) | |||||
EndIf ( ) | |||||
EndForEach ( ) |
@@ -0,0 +1,6 @@ | |||||
{ | |||||
"files.trimTrailingWhitespace": true, | |||||
"files.trimFinalNewlines": true, | |||||
"files.insertFinalNewline": true, | |||||
"files.eol": "\n" | |||||
} |
@@ -1,63 +1,63 @@ | |||||
# Initialize CMake ################################################################################ | # Initialize CMake ################################################################################ | ||||
CMake_Minimum_Required ( VERSION 3.12.0 FATAL_ERROR ) | |||||
CMake_Minimum_Required ( VERSION 3.12.0 FATAL_ERROR ) | |||||
# Set CMAKE_BUILD_TYPE | # Set CMAKE_BUILD_TYPE | ||||
If ( NOT CMAKE_BUILD_TYPE ) | |||||
Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE ) | |||||
EndIf ( NOT CMAKE_BUILD_TYPE ) | |||||
Set_Property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel ) | |||||
If ( NOT CMAKE_BUILD_TYPE ) | |||||
Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE ) | |||||
EndIf ( NOT CMAKE_BUILD_TYPE ) | |||||
Set_Property ( CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS Debug Release RelWithDebInfo MinSizeRel ) | |||||
# Set CMAKE_MODULE_PATH | # Set CMAKE_MODULE_PATH | ||||
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
EndIf ( ) | |||||
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" ) | |||||
EndIf ( ) | |||||
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/" ) | |||||
EndIf ( ) | |||||
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/cmake" ) | |||||
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} | |||||
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules/cmake" ) | |||||
EndIf ( ) | |||||
# Project ######################################################################################### | # Project ######################################################################################### | ||||
Include ( CTest ) | |||||
Include ( GNUInstallDirs ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libinterface-options.cmake ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libinterface-const.cmake ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libinterface-var.cmake ) | |||||
Project ( ${LIBINTERFACE_PROJECT_NAME} | |||||
DESCRIPTION "${LIBINTERFACE_PROJECT_DESCRIPTION}" | |||||
VERSION "${LIBINTERFACE_VERSION}" ) | |||||
Include ( GNUInstallDirs ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libinterface-options.cmake ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libinterface-const.cmake ) | |||||
Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libinterface-var.cmake ) | |||||
Project ( ${LIBINTERFACE_PROJECT_NAME} | |||||
DESCRIPTION "${LIBINTERFACE_PROJECT_DESCRIPTION}" | |||||
VERSION "${LIBINTERFACE_VERSION}" ) | |||||
Include ( CTest ) | |||||
# Subdirectories | # Subdirectories | ||||
Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) | |||||
Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/test ) | |||||
Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/src ) | |||||
Add_SubDirectory ( ${CMAKE_CURRENT_SOURCE_DIR}/test ) | |||||
# Install | # Install | ||||
If ( NOT LIBINTERFACE_HAS_EXPORT | |||||
OR NOT LIBINTERFACE_INSTALL_PACKAGE ) | |||||
Return ( ) | |||||
EndIf ( ) | |||||
Include ( CMakePackageConfigHelpers ) | |||||
Write_Basic_Package_Version_File ( "${CMAKE_CURRENT_BINARY_DIR}/cmake/libinterface-config-version.cmake" | |||||
VERSION ${LIBINTERFACE_VERSION} | |||||
COMPATIBILITY AnyNewerVersion ) | |||||
Configure_File ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/libinterface-config.cmake" | |||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/libinterface-config.cmake" | |||||
@ONLY ) | |||||
Set ( ConfigPackageLocation "${LIBINTERFACE_INSTALL_DIR_SHARE}/cmake" ) | |||||
Install ( EXPORT | |||||
libinterface | |||||
NAMESPACE | |||||
libinterface:: | |||||
DESTINATION | |||||
${ConfigPackageLocation} ) | |||||
Install ( FILES | |||||
If ( NOT LIBINTERFACE_HAS_EXPORT | |||||
OR NOT LIBINTERFACE_INSTALL_PACKAGE ) | |||||
Return ( ) | |||||
EndIf ( ) | |||||
Include ( CMakePackageConfigHelpers ) | |||||
Write_Basic_Package_Version_File ( "${CMAKE_CURRENT_BINARY_DIR}/cmake/libinterface-config-version.cmake" | |||||
VERSION ${LIBINTERFACE_VERSION} | |||||
COMPATIBILITY AnyNewerVersion ) | |||||
Configure_File ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/libinterface-config.cmake" | |||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/libinterface-config.cmake" | "${CMAKE_CURRENT_BINARY_DIR}/cmake/libinterface-config.cmake" | ||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/libinterface-config-version.cmake" | |||||
DESTINATION | |||||
${ConfigPackageLocation} | |||||
COMPONENT | |||||
Devel ) | |||||
@ONLY ) | |||||
Set ( ConfigPackageLocation "${LIBINTERFACE_INSTALL_DIR_SHARE}/cmake" ) | |||||
Install ( EXPORT | |||||
libinterface | |||||
NAMESPACE | |||||
libinterface:: | |||||
DESTINATION | |||||
${ConfigPackageLocation} ) | |||||
Install ( FILES | |||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/libinterface-config.cmake" | |||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake/libinterface-config-version.cmake" | |||||
DESTINATION | |||||
${ConfigPackageLocation} | |||||
COMPONENT | |||||
Devel ) |
@@ -0,0 +1,3 @@ | |||||
# libinterface | |||||
Readme of the project. |
@@ -1,28 +1,28 @@ | |||||
# This file contains constant variables that are fixed to this project | # This file contains constant variables that are fixed to this project | ||||
# Version | # Version | ||||
Set ( LIBINTERFACE_VERSION_MAJOR 1 ) | |||||
Set ( LIBINTERFACE_VERSION_MINOR 0 ) | |||||
Set ( LIBINTERFACE_VERSION_PATCH 0 ) | |||||
Set ( LIBINTERFACE_VERSION_BUILD 0 ) | |||||
Set ( LIBINTERFACE_VERSION_HASH "" ) | |||||
Set ( LIBINTERFACE_VERSION_BEHIND 0 ) | |||||
Set ( LIBINTERFACE_VERSION_DIRTY 0 ) | |||||
Set ( LIBINTERFACE_VERSION_MAJOR 1 ) | |||||
Set ( LIBINTERFACE_VERSION_MINOR 0 ) | |||||
Set ( LIBINTERFACE_VERSION_PATCH 0 ) | |||||
Set ( LIBINTERFACE_VERSION_BUILD 0 ) | |||||
Set ( LIBINTERFACE_VERSION_HASH "" ) | |||||
Set ( LIBINTERFACE_VERSION_BEHIND 0 ) | |||||
Set ( LIBINTERFACE_VERSION_DIRTY 0 ) | |||||
# Names | # Names | ||||
Set ( LIBINTERFACE_PROJECT_NAME "libinterface" ) | |||||
Set ( LIBINTERFACE_PROJECT_DESCRIPTION "A simple interface library" ) | |||||
Set ( LIBINTERFACE_PROJECT_NAME "libinterface" ) | |||||
Set ( LIBINTERFACE_PROJECT_DESCRIPTION "A simple interface library" ) | |||||
# Include generated variables for further usage | # Include generated variables for further usage | ||||
Include ( ${CMAKE_CURRENT_LIST_DIR}/libinterface-var.cmake ) | |||||
Include ( ${CMAKE_CURRENT_LIST_DIR}/libinterface-var.cmake ) | |||||
# Install directories | # Install directories | ||||
Set ( LIBINTERFACE_INSTALL_DIR_INCLUDE "${CMAKE_INSTALL_INCLUDEDIR}/${LIBINTERFACE_NAME}" ) | |||||
Set ( LIBINTERFACE_INSTALL_DIR_LIB "${CMAKE_INSTALL_LIBDIR}" ) | |||||
Set ( LIBINTERFACE_INSTALL_DIR_SHARE "${CMAKE_INSTALL_DATAROOTDIR}/${LIBINTERFACE_NAME}" ) | |||||
Set ( LIBINTERFACE_INSTALL_DIR_INCLUDE "${CMAKE_INSTALL_INCLUDEDIR}/${LIBINTERFACE_NAME}" ) | |||||
Set ( LIBINTERFACE_INSTALL_DIR_LIB "${CMAKE_INSTALL_LIBDIR}" ) | |||||
Set ( LIBINTERFACE_INSTALL_DIR_SHARE "${CMAKE_INSTALL_DATAROOTDIR}/${LIBINTERFACE_NAME}" ) | |||||
# C Standard | # C Standard | ||||
Set ( CMAKE_C_STANDARD 11 ) | |||||
Set ( CMAKE_CXX_STANDARD 17 ) | |||||
Set ( CMAKE_C_STANDARD_REQUIRED ON ) | |||||
Set ( CMAKE_CXX_STANDARD_REQUIRED ON ) | |||||
Set ( CMAKE_C_STANDARD 11 ) | |||||
Set ( CMAKE_CXX_STANDARD 17 ) | |||||
Set ( CMAKE_C_STANDARD_REQUIRED ON ) | |||||
Set ( CMAKE_CXX_STANDARD_REQUIRED ON ) |
@@ -1,11 +1,11 @@ | |||||
# This file contains options that can be passed to the cmake command | # This file contains options that can be passed to the cmake command | ||||
Option ( LIBINTERFACE_INSTALL_HEADER | |||||
"Install headers of libinterface." | |||||
ON ) | |||||
Option ( LIBINTERFACE_INSTALL_PACKAGE | |||||
"Install the cmake package of libinterface." | |||||
ON ) | |||||
Option ( LIBINTERFACE_USE_GIT_VERSION | |||||
"Read the git tags to get the version of libinterface" | |||||
ON ) | |||||
Option ( LIBINTERFACE_INSTALL_HEADER | |||||
"Install headers of libinterface." | |||||
ON ) | |||||
Option ( LIBINTERFACE_INSTALL_PACKAGE | |||||
"Install the cmake package of libinterface." | |||||
ON ) | |||||
Option ( LIBINTERFACE_USE_GIT_VERSION | |||||
"Read the git tags to get the version of libinterface" | |||||
ON ) |
@@ -1,26 +1,32 @@ | |||||
# This file contains generated variables that are needed for the project | # This file contains generated variables that are needed for the project | ||||
# Git Version | # Git Version | ||||
If ( LIBINTERFACE_USE_GIT_VERSION ) | |||||
Include ( git_helper OPTIONAL RESULT_VARIABLE HAS_GIT_HELPER ) | |||||
If ( HAS_GIT_HELPER ) | |||||
GitGetVersion ( ${CMAKE_CURRENT_LIST_DIR}/.. | |||||
LIBINTERFACE_VERSION_MAJOR | |||||
LIBINTERFACE_VERSION_MINOR | |||||
LIBINTERFACE_VERSION_PATCH | |||||
LIBINTERFACE_VERSION_BUILD | |||||
LIBINTERFACE_VERSION_HASH | |||||
LIBINTERFACE_VERSION_BEHIND | |||||
LIBINTERFACE_VERSION_DIRTY ) | |||||
EndIf ( ) | |||||
EndIf ( ) | |||||
If ( LIBINTERFACE_USE_GIT_VERSION ) | |||||
Include ( git_helper OPTIONAL RESULT_VARIABLE HAS_GIT_HELPER ) | |||||
If ( HAS_GIT_HELPER ) | |||||
GitGetVersion ( ${CMAKE_CURRENT_LIST_DIR}/.. | |||||
LIBINTERFACE_VERSION_MAJOR | |||||
LIBINTERFACE_VERSION_MINOR | |||||
LIBINTERFACE_VERSION_PATCH | |||||
LIBINTERFACE_VERSION_BUILD | |||||
LIBINTERFACE_VERSION_HASH | |||||
LIBINTERFACE_VERSION_BEHIND | |||||
LIBINTERFACE_VERSION_DIRTY ) | |||||
EndIf ( ) | |||||
EndIf ( ) | |||||
# Strings | # Strings | ||||
Set ( LIBINTERFACE_VERSION_SHORT "${LIBINTERFACE_VERSION_MAJOR}.${LIBINTERFACE_VERSION_MINOR}" ) | |||||
Set ( LIBINTERFACE_VERSION "${LIBINTERFACE_VERSION_SHORT}.${LIBINTERFACE_VERSION_PATCH}.${LIBINTERFACE_VERSION_BUILD}" ) | |||||
Set ( LIBINTERFACE_VERSION_COMPLETE "${LIBINTERFACE_VERSION}" ) | |||||
Set ( LIBINTERFACE_NAME "${LIBINTERFACE_PROJECT_NAME}-${LIBINTERFACE_VERSION_SHORT}" ) | |||||
Set ( LIBINTERFACE_OUTPUTNAME "${LIBINTERFACE_PROJECT_NAME}" ) | |||||
If ( LIBINTERFACE_VERSION_BEHIND ) | |||||
Set ( LIBINTERFACE_VERSION_COMPLETE "${LIBINTERFACE_VERSION_COMPLETE}+${LIBINTERFACE_VERSION_BEHIND}" ) | |||||
EndIf ( ) | |||||
Set ( LIBINTERFACE_VERSION_SHORT | |||||
"${LIBINTERFACE_VERSION_MAJOR}.${LIBINTERFACE_VERSION_MINOR}" ) | |||||
Set ( LIBINTERFACE_VERSION | |||||
"${LIBINTERFACE_VERSION_SHORT}.${LIBINTERFACE_VERSION_PATCH}.${LIBINTERFACE_VERSION_BUILD}" ) | |||||
Set ( LIBINTERFACE_VERSION_COMPLETE | |||||
"${LIBINTERFACE_VERSION}" ) | |||||
Set ( LIBINTERFACE_NAME | |||||
"${LIBINTERFACE_PROJECT_NAME}-${LIBINTERFACE_VERSION_SHORT}" ) | |||||
Set ( LIBINTERFACE_OUTPUTNAME | |||||
"${LIBINTERFACE_PROJECT_NAME}" ) | |||||
If ( LIBINTERFACE_VERSION_BEHIND ) | |||||
Set ( LIBINTERFACE_VERSION_COMPLETE | |||||
"${LIBINTERFACE_VERSION_COMPLETE}+${LIBINTERFACE_VERSION_BEHIND}" ) | |||||
EndIf ( ) |
@@ -1,30 +1,30 @@ | |||||
# Initialize ###################################################################################### | # Initialize ###################################################################################### | ||||
Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | |||||
Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||||
Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) | |||||
Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | |||||
Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||||
Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) | |||||
# Interface Library ############################################################################### | # Interface Library ############################################################################### | ||||
Set ( LIBINTERFACE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include ) | |||||
Add_Library ( libinterface INTERFACE ) | |||||
Target_Include_Directories ( libinterface | |||||
INTERFACE | |||||
$<BUILD_INTERFACE:${LIBINTERFACE_INCLUDE_DIR}> | |||||
$<INSTALL_INTERFACE:${LIBINTERFACE_INSTALL_DIR_INCLUDE}> ) | |||||
Set ( LIBINTERFACE_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../include ) | |||||
Add_Library ( libinterface INTERFACE ) | |||||
Target_Include_Directories ( libinterface | |||||
INTERFACE | |||||
$<BUILD_INTERFACE:${LIBINTERFACE_INCLUDE_DIR}> | |||||
$<INSTALL_INTERFACE:${LIBINTERFACE_INSTALL_DIR_INCLUDE}> ) | |||||
# Install ######################################################################################### | # Install ######################################################################################### | ||||
Set ( LIBINTERFACE_HAS_EXPORT False PARENT_SCOPE ) | |||||
Set ( LIBINTERFACE_HAS_EXPORT False PARENT_SCOPE ) | |||||
# Header | # Header | ||||
If ( LIBINTERFACE_INSTALL_HEADER ) | |||||
Set ( LIBINTERFACE_HAS_EXPORT True PARENT_SCOPE ) | |||||
Install ( FILES ${LIBINTERFACE_INCLUDE_DIR}/libinterface.h | |||||
DESTINATION ${LIBINTERFACE_INSTALL_DIR_INCLUDE} ) | |||||
Install ( DIRECTORY ${LIBINTERFACE_INCLUDE_DIR}/libinterface | |||||
DESTINATION ${LIBINTERFACE_INSTALL_DIR_INCLUDE} ) | |||||
Install ( TARGETS libinterface | |||||
EXPORT libinterface | |||||
DESTINATION ${LIBINTERFACE_INSTALL_DIR_INCLUDE} ) | |||||
EndIf ( ) | |||||
If ( LIBINTERFACE_INSTALL_HEADER ) | |||||
Set ( LIBINTERFACE_HAS_EXPORT True PARENT_SCOPE ) | |||||
Install ( FILES ${LIBINTERFACE_INCLUDE_DIR}/libinterface.h | |||||
DESTINATION ${LIBINTERFACE_INSTALL_DIR_INCLUDE} ) | |||||
Install ( DIRECTORY ${LIBINTERFACE_INCLUDE_DIR}/libinterface | |||||
DESTINATION ${LIBINTERFACE_INSTALL_DIR_INCLUDE} ) | |||||
Install ( TARGETS libinterface | |||||
EXPORT libinterface | |||||
DESTINATION ${LIBINTERFACE_INSTALL_DIR_INCLUDE} ) | |||||
EndIf ( ) |
@@ -1,52 +1,59 @@ | |||||
# Initialize ###################################################################################### | # Initialize ###################################################################################### | ||||
Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | |||||
Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||||
Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS ) | |||||
Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE ) | |||||
Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) | |||||
Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS ) | |||||
Find_Package ( Sanitizers QUIET ) | |||||
# Test ############################################################################################ | # Test ############################################################################################ | ||||
Find_Package ( GTest ) | |||||
If ( NOT "${GTest_FOUND}" ) | |||||
Return ( ) | |||||
EndIf ( ) | |||||
Find_Package ( GTest ) | |||||
If ( NOT "${GTest_FOUND}" ) | |||||
Return ( ) | |||||
EndIf ( ) | |||||
File ( GLOB_RECURSE LIBINTERFACE_TEST_HEADER_FILES | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.h ) | |||||
File ( GLOB_RECURSE LIBINTERFACE_TEST_INLINE_FILES | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.inl ) | |||||
File ( GLOB_RECURSE LIBINTERFACE_TEST_SOURCE_FILES | |||||
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||||
File ( GLOB_RECURSE LIBINTERFACE_TEST_HEADER_FILES | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.h ) | |||||
File ( GLOB_RECURSE LIBINTERFACE_TEST_INLINE_FILES | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.inl ) | |||||
File ( GLOB_RECURSE LIBINTERFACE_TEST_SOURCE_FILES | |||||
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} | |||||
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp ) | |||||
ForEach ( FILE IN LISTS LIBINTERFACE_TEST_SOURCE_FILES ) | |||||
ForEach ( FILE IN LISTS LIBINTERFACE_TEST_SOURCE_FILES ) | |||||
# add test | # add test | ||||
Get_Filename_Component ( TEST_DIR ${FILE} DIRECTORY ) | |||||
Get_Filename_Component ( TEST_NAME ${FILE} NAME_WE ) | |||||
Set ( TEST_NAME "${TEST_DIR}/${TEST_NAME}" ) | |||||
String ( REPLACE "\\" "-" TEST_NAME "${TEST_NAME}" ) | |||||
String ( REPLACE "/" "-" TEST_NAME "${TEST_NAME}" ) | |||||
String ( REPLACE "_" "-" TEST_NAME "${TEST_NAME}" ) | |||||
Set ( TEST_NAME "test-${TEST_NAME}" ) | |||||
Add_Executable ( ${TEST_NAME} | |||||
EXCLUDE_FROM_ALL | |||||
${LIBINTERFACE_TEST_HEADER_FILES} | |||||
${LIBINTERFACE_TEST_INLINE_FILES} | |||||
${FILE} ) | |||||
Target_Link_Libraries ( ${TEST_NAME} | |||||
PUBLIC | |||||
libinterface | |||||
GTest::Main ) | |||||
Get_Filename_Component ( TEST_DIR ${FILE} DIRECTORY ) | |||||
Get_Filename_Component ( TEST_NAME ${FILE} NAME_WE ) | |||||
Set ( TEST_NAME "${TEST_DIR}/${TEST_NAME}" ) | |||||
String ( REPLACE "\\" "-" TEST_NAME "${TEST_NAME}" ) | |||||
String ( REPLACE "/" "-" TEST_NAME "${TEST_NAME}" ) | |||||
String ( REPLACE "_" "-" TEST_NAME "${TEST_NAME}" ) | |||||
Set ( TEST_NAME "test-${TEST_NAME}" ) | |||||
Add_Executable ( ${TEST_NAME} | |||||
EXCLUDE_FROM_ALL | |||||
${LIBINTERFACE_TEST_HEADER_FILES} | |||||
${LIBINTERFACE_TEST_INLINE_FILES} | |||||
${FILE} ) | |||||
Target_Link_Libraries ( ${TEST_NAME} | |||||
PUBLIC | |||||
libinterface | |||||
GTest::Main ) | |||||
# Sanitizers | |||||
If ( Sanitizers_FOUND ) | |||||
Add_Sanitizers ( ${TEST_NAME} ) | |||||
EndIf ( ) | |||||
# pedantic | # pedantic | ||||
If ( HAS_PEDANTIC ) | |||||
Pedantic_Apply_Flags_Target ( ${TEST_NAME} ALL ) | |||||
EndIf ( ) | |||||
If ( HAS_PEDANTIC ) | |||||
Pedantic_Apply_Flags_Target ( ${TEST_NAME} ALL ) | |||||
EndIf ( ) | |||||
# test | # test | ||||
If ( HAS_CMAKE_TESTS ) | |||||
Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} ) | |||||
Else ( ) | |||||
Add_Test ( NAME ${TEST_NAME} COMMAND ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) | |||||
EndIf ( ) | |||||
EndForEach ( ) | |||||
If ( HAS_CMAKE_TESTS ) | |||||
Add_CMake_Test ( NAME ${TEST_NAME} TARGET ${TEST_NAME} ) | |||||
Else ( ) | |||||
Add_Test ( NAME ${TEST_NAME} COMMAND ${TEST_NAME} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) | |||||
EndIf ( ) | |||||
EndForEach ( ) |
@@ -3,6 +3,7 @@ | |||||
ScriptFile=$(readlink -f "${BASH_SOURCE[0]}") | ScriptFile=$(readlink -f "${BASH_SOURCE[0]}") | ||||
ScriptDir=$(dirname "${ScriptFile}") | ScriptDir=$(dirname "${ScriptFile}") | ||||
IgnoreVsCodeSettings=1 | |||||
UseGit=1 | UseGit=1 | ||||
Verbose=0 | Verbose=0 | ||||
Update=0 | Update=0 | ||||
@@ -48,7 +49,7 @@ Parameters: | |||||
-l|--library <name> <directory> | -l|--library <name> <directory> | ||||
Create a new library project with the given name at the given directory. | Create a new library project with the given name at the given directory. | ||||
-e|--executable <name ><directory> | |||||
-e|--executable <name> <directory> | |||||
Create a new executable project with the given name at the given directory. | Create a new executable project with the given name at the given directory. | ||||
-m|--modules <remote> | -m|--modules <remote> | ||||
@@ -61,6 +62,9 @@ Parameters: | |||||
-u|--update | -u|--update | ||||
Update an exsisting project. | Update an exsisting project. | ||||
-s|--vscode | |||||
Add default settings for visual studio code | |||||
-v|--verbose | -v|--verbose | ||||
Print extra debug output. | Print extra debug output. | ||||
@@ -121,6 +125,12 @@ function CreateGroup() | |||||
if [[ -n "$CMakeModules" ]]; then | if [[ -n "$CMakeModules" ]]; then | ||||
git -C $dir submodule add $CMakeModulesForced "$CMakeModules" "cmake/modules" \ | git -C $dir submodule add $CMakeModulesForced "$CMakeModules" "cmake/modules" \ | ||||
|| Panic "Git submodule add failed!" | || Panic "Git submodule add failed!" | ||||
git -C $dir/cmake/modules fetch --all \ | |||||
|| Panic "Git submodule fetch failed!" | |||||
git -C $dir/cmake/modules reset --hard origin/master \ | |||||
|| Panic "Git submodule reset failed!" | |||||
fi | fi | ||||
fi | fi | ||||
@@ -128,21 +138,32 @@ function CreateGroup() | |||||
Log " Copy files" | Log " Copy files" | ||||
srcDir="$ScriptDir" | srcDir="$ScriptDir" | ||||
for file in $(find $srcDir -type f); do | for file in $(find $srcDir -type f); do | ||||
# Ignore unrelated files | |||||
if [[ $file == $ScriptFile ]] \ | if [[ $file == $ScriptFile ]] \ | ||||
|| [[ $file == $srcDir/build/* ]] \ | || [[ $file == $srcDir/build/* ]] \ | ||||
|| [[ $file == $srcDir/.git/* ]] \ | || [[ $file == $srcDir/.git/* ]] \ | ||||
|| [[ $file == $srcDir/.gitmodules ]] \ | || [[ $file == $srcDir/.gitmodules ]] \ | ||||
|| [[ $file == $srcDir/.vscode/* ]] \ | |||||
|| [[ $file == $srcDir/projects/* ]] \ | || [[ $file == $srcDir/projects/* ]] \ | ||||
|| [[ $file == $srcDir/cmake/modules/* ]] | || [[ $file == $srcDir/cmake/modules/* ]] | ||||
then | then | ||||
relFile=.${file/$srcDir/} | relFile=.${file/$srcDir/} | ||||
Verbose " Ignore $relFile" | Verbose " Ignore $relFile" | ||||
# Ignore .vscode settings | |||||
elif [[ IgnoreVsCodeSettings -eq 1 ]] \ | |||||
&& [[ $file == $srcDir/.vscode/* ]] | |||||
then | |||||
relFile=.${file/$srcDir/} | |||||
Verbose " Ignore $relFile" | |||||
# Ignore git files | |||||
elif [[ $UseGit -eq 0 ]] \ | elif [[ $UseGit -eq 0 ]] \ | ||||
&& [[ $file == $srcDir/.git* ]] | && [[ $file == $srcDir/.git* ]] | ||||
then | then | ||||
relFile=.${file/$srcDir/} | relFile=.${file/$srcDir/} | ||||
Verbose " Ignore $relFile" | Verbose " Ignore $relFile" | ||||
# Copy related files | |||||
else | else | ||||
Copy "$srcDir" "$dir" "${file/$srcDir/}" | Copy "$srcDir" "$dir" "${file/$srcDir/}" | ||||
fi | fi | ||||
@@ -161,17 +182,33 @@ function CreateProject() | |||||
mkdir -p "$dir" \ | mkdir -p "$dir" \ | ||||
|| Panic "Unable to create directory: $dir!" | || Panic "Unable to create directory: $dir!" | ||||
# Create git repository | |||||
Log " Create git repository" | |||||
if [[ $UseGit -eq 1 ]]; then | |||||
# Create/Update git repository | |||||
if [[ $Update -eq 1 ]]; then | |||||
if [[ -e "$dir/cmake/modules/.git" ]]; then | |||||
Log " Update git submodule for CMake modules" | |||||
git -C "$dir/cmake/modules" fetch origin \ | |||||
|| Panic "Unable to fetch cmake module!" | |||||
git -C "$dir/cmake/modules" checkout master \ | |||||
|| Panic "Unable to checkout cmake module!" | |||||
git -C "$dir/cmake/modules" reset --hard origin/master \ | |||||
|| Panic "Unable to reset cmake module!" | |||||
fi | |||||
elif [[ $UseGit -eq 1 ]]; then | |||||
Log " Create git repository" | |||||
git -C $dir init \ | git -C $dir init \ | ||||
|| Panic "Git init failed!" | || Panic "Git init failed!" | ||||
# Add cmake modules | # Add cmake modules | ||||
Log " Add git submodule for CMake modules" | |||||
if [[ -n "$CMakeModules" ]]; then | if [[ -n "$CMakeModules" ]]; then | ||||
Log " Add git submodule for CMake modules" | |||||
git -C $dir submodule add $CMakeModulesForced "$CMakeModules" "cmake/modules" \ | git -C $dir submodule add $CMakeModulesForced "$CMakeModules" "cmake/modules" \ | ||||
|| Panic "Git submodule add failed!" | || Panic "Git submodule add failed!" | ||||
git -C $dir/cmake/modules fetch --all \ | |||||
|| Panic "Git submodule fetch failed!" | |||||
git -C $dir/cmake/modules reset --hard origin/master \ | |||||
|| Panic "Git submodule reset failed!" | |||||
fi | fi | ||||
fi | fi | ||||
@@ -191,6 +228,13 @@ function CreateProject() | |||||
relFile=.${file/$srcDir/} | relFile=.${file/$srcDir/} | ||||
Verbose " Ignore $relFile" | Verbose " Ignore $relFile" | ||||
# Ignore .vscode settings | |||||
elif [[ IgnoreVsCodeSettings -eq 1 ]] \ | |||||
&& [[ $file == $srcDir/.vscode/* ]] | |||||
then | |||||
relFile=.${file/$srcDir/} | |||||
Verbose " Ignore $relFile" | |||||
# ignore git files | # ignore git files | ||||
elif [[ $UseGit -eq 0 ]] \ | elif [[ $UseGit -eq 0 ]] \ | ||||
&& [[ $file == $srcDir/.git* ]] | && [[ $file == $srcDir/.git* ]] | ||||
@@ -275,6 +319,10 @@ while [ $# -gt 0 ]; do | |||||
Update=1 | Update=1 | ||||
;; | ;; | ||||
"-s" | "--vscode") | |||||
IgnoreVsCodeSettings=0 | |||||
;; | |||||
"-n" | "--nogit" ) | "-n" | "--nogit" ) | ||||
UseGit=0 | UseGit=0 | ||||
;; | ;; | ||||