diff --git a/projects/helloworld/CMakeLists.txt b/projects/helloworld/CMakeLists.txt index b29e5c7..0d61243 100644 --- a/projects/helloworld/CMakeLists.txt +++ b/projects/helloworld/CMakeLists.txt @@ -20,7 +20,8 @@ EndIf ( ) # Project ######################################################################################### -Include ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/helloworld-var.cmake" ) +Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/helloworld-var.cmake ) +Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/helloworld-options.cmake ) Project ( helloworld DESCRIPTION "A simple library" VERSION "${HELLOWORLD_VERSION}" ) diff --git a/projects/helloworld/cmake/helloworld-options.cmake b/projects/helloworld/cmake/helloworld-options.cmake new file mode 100644 index 0000000..d7e4011 --- /dev/null +++ b/projects/helloworld/cmake/helloworld-options.cmake @@ -0,0 +1,6 @@ +Option ( HELLOWORLD_INSTALL_DEBUG + "Install the stripped debug informations of helloworld." + OFF ) +Option ( HELLOWORLD_NO_STRIP + "Do not strip debug symbols from binary." + OFF ) diff --git a/projects/helloworld/src/CMakeLists.txt b/projects/helloworld/src/CMakeLists.txt index f25e1e0..3a8fb81 100644 --- a/projects/helloworld/src/CMakeLists.txt +++ b/projects/helloworld/src/CMakeLists.txt @@ -4,13 +4,6 @@ Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) -Option ( HELLOWORLD_INSTALL_DEBUG - "Install the stripped debug informations of helloworld." - OFF ) -Option ( HELLOWORLD_NO_STRIP - "Do not strip debug symbols from binary." - OFF ) - Message ( WARNING "Please configure the dependencies of this project!" ) Find_Package ( libhelloworld REQUIRED ) diff --git a/projects/libhelloworld/CMakeLists.txt b/projects/libhelloworld/CMakeLists.txt index a3e642c..3ec179e 100644 --- a/projects/libhelloworld/CMakeLists.txt +++ b/projects/libhelloworld/CMakeLists.txt @@ -20,7 +20,8 @@ EndIf ( ) # Project ######################################################################################### -Include ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/libhelloworld-var.cmake" ) +Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libhelloworld-var.cmake ) +Include ( ${CMAKE_CURRENT_SOURCE_DIR}/cmake/libhelloworld-options.cmake ) Project ( libhelloworld DESCRIPTION "A simple library" VERSION "${LIBHELLOWORLD_VERSION}" ) diff --git a/projects/libhelloworld/cmake/libhelloworld-options.cmake b/projects/libhelloworld/cmake/libhelloworld-options.cmake new file mode 100644 index 0000000..21607ab --- /dev/null +++ b/projects/libhelloworld/cmake/libhelloworld-options.cmake @@ -0,0 +1,15 @@ +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_NO_STRIP + "Do not strip debug symbols from binary." + OFF ) diff --git a/projects/libhelloworld/src/CMakeLists.txt b/projects/libhelloworld/src/CMakeLists.txt index 0a55ce0..f668abe 100644 --- a/projects/libhelloworld/src/CMakeLists.txt +++ b/projects/libhelloworld/src/CMakeLists.txt @@ -4,22 +4,6 @@ Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) -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_NO_STRIP - "Do not strip debug symbols from binary." - OFF ) - # Object Library ################################################################################## Set ( CMAKE_POSITION_INDEPENDENT_CODE ON ) diff --git a/tool b/tool index 64d45c1..a8b5a63 100755 --- a/tool +++ b/tool @@ -6,6 +6,7 @@ ScriptDir=$(dirname "${ScriptFile}") UseGit=1 Verbose=0 CMakeModules="" +CMakeModulesForced="" Operations=() function Log() @@ -27,7 +28,7 @@ function Error() function Panic() { - Error $@ + Error "$@" exit 1 } @@ -47,7 +48,8 @@ Parameters: Create a new executable project with the given name at the given directory. -m|--modules - Add the CMake Modules fromthe given remote repository as submodule of the new project. + -M|--force-modules + Add the CMake Modules from the given remote repository as submodule of the new project. -n|--nogit Does not initialize a new git repository when creating a new project group. @@ -110,7 +112,7 @@ function CreateGroup() # Add cmake modules Log " Add git submodule for CMake modules" if [[ -n "$CMakeModules" ]]; then - git -C $dir submodule add "$CMakeModules" "$dir/cmake/modules" \ + git -C $dir submodule add $CMakeModulesForced "$CMakeModules" "$dir/cmake/modules" \ || Panic "Git submodule add failed!" fi fi @@ -151,10 +153,18 @@ function CreateLibrary() mkdir -p "$dir" \ || Panic "Unable to create directory: $dir!" - # Add cmake modules - if [[ $UseGit -eq 1 ]] && [[ -n "$CMakeModules" ]]; then - git -C $dir submodule add "$CMakeModules" "$dir/cmake/modules" \ - || Panic "Git submodule add failed!" + # Create git repository + Log " Create git repository" + if [[ $UseGit -eq 1 ]]; then + git -C $dir init \ + || Panic "Git init failed!" + + # Add cmake modules + Log " Add git submodule for CMake modules" + if [[ -n "$CMakeModules" ]]; then + git -C $dir submodule add $CMakeModulesForced "$CMakeModules" "$dir/cmake/modules" \ + || Panic "Git submodule add failed!" + fi fi # Copy files @@ -188,10 +198,18 @@ function CreateExecutable() mkdir -p "$dir" \ || Panic "Unable to create directory: $dir!" - # Add cmake modules - if [[ $UseGit -eq 1 ]] && [[ -n "$CMakeModules" ]]; then - git -C $dir submodule add "$CMakeModules" "$dir/cmake/modules" \ - || Panic "Git submodule add failed!" + # Create git repository + Log " Create git repository" + if [[ $UseGit -eq 1 ]]; then + git -C $dir init \ + || Panic "Git init failed!" + + # Add cmake modules + Log " Add git submodule for CMake modules" + if [[ -n "$CMakeModules" ]]; then + git -C $dir submodule add $CMakeModulesForced "$CMakeModules" "$dir/cmake/modules" \ + || Panic "Git submodule add failed!" + fi fi # Copy files @@ -254,6 +272,15 @@ while [ $# -gt 0 ]; do shift ;; + "-M" | "--force-modules" ) + if [ $# -lt 2 ]; then + Panic "Parameter $1 expects exactly one parameter!" + fi + CMakeModules="$2" + CMakeModulesForced="--force" + shift + ;; + "-n" | "--nogit" ) UseGit=0 ;;