Просмотр исходного кода

* Moved all options of a project to an extra options cmake script

* Improved tool (git handling)
master
bergmann 6 лет назад
Родитель
Сommit
95975b8824
7 измененных файлов: 63 добавлений и 36 удалений
  1. +2
    -1
      projects/helloworld/CMakeLists.txt
  2. +6
    -0
      projects/helloworld/cmake/helloworld-options.cmake
  3. +0
    -7
      projects/helloworld/src/CMakeLists.txt
  4. +2
    -1
      projects/libhelloworld/CMakeLists.txt
  5. +15
    -0
      projects/libhelloworld/cmake/libhelloworld-options.cmake
  6. +0
    -16
      projects/libhelloworld/src/CMakeLists.txt
  7. +38
    -11
      tool

+ 2
- 1
projects/helloworld/CMakeLists.txt Просмотреть файл

@@ -20,7 +20,8 @@ EndIf ( )


# Project ######################################################################################### # 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 Project ( helloworld
DESCRIPTION "A simple library" DESCRIPTION "A simple library"
VERSION "${HELLOWORLD_VERSION}" ) VERSION "${HELLOWORLD_VERSION}" )


+ 6
- 0
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 )

+ 0
- 7
projects/helloworld/src/CMakeLists.txt Просмотреть файл

@@ -4,13 +4,6 @@ Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE
Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC )
Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) 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!" ) Message ( WARNING "Please configure the dependencies of this project!" )
Find_Package ( libhelloworld REQUIRED ) Find_Package ( libhelloworld REQUIRED )




+ 2
- 1
projects/libhelloworld/CMakeLists.txt Просмотреть файл

@@ -20,7 +20,8 @@ EndIf ( )


# Project ######################################################################################### # 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 Project ( libhelloworld
DESCRIPTION "A simple library" DESCRIPTION "A simple library"
VERSION "${LIBHELLOWORLD_VERSION}" ) VERSION "${LIBHELLOWORLD_VERSION}" )


+ 15
- 0
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 )

+ 0
- 16
projects/libhelloworld/src/CMakeLists.txt Просмотреть файл

@@ -4,22 +4,6 @@ Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE
Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC ) Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC )
Include ( strip_symbols OPTIONAL RESULT_VARIABLE HAS_STRIP_SYMBOLS ) 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 ################################################################################## # Object Library ##################################################################################


Set ( CMAKE_POSITION_INDEPENDENT_CODE ON ) Set ( CMAKE_POSITION_INDEPENDENT_CODE ON )


+ 38
- 11
tool Просмотреть файл

@@ -6,6 +6,7 @@ ScriptDir=$(dirname "${ScriptFile}")
UseGit=1 UseGit=1
Verbose=0 Verbose=0
CMakeModules="" CMakeModules=""
CMakeModulesForced=""
Operations=() Operations=()


function Log() function Log()
@@ -27,7 +28,7 @@ function Error()


function Panic() function Panic()
{ {
Error $@
Error "$@"
exit 1 exit 1
} }


@@ -47,7 +48,8 @@ Parameters:
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>
Add the CMake Modules fromthe given remote repository as submodule of the new project.
-M|--force-modules <remote>
Add the CMake Modules from the given remote repository as submodule of the new project.


-n|--nogit -n|--nogit
Does not initialize a new git repository when creating a new project group. Does not initialize a new git repository when creating a new project group.
@@ -110,7 +112,7 @@ function CreateGroup()
# Add cmake modules # Add cmake modules
Log " Add git submodule for CMake modules" Log " Add git submodule for CMake modules"
if [[ -n "$CMakeModules" ]]; then 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!" || Panic "Git submodule add failed!"
fi fi
fi fi
@@ -151,10 +153,18 @@ function CreateLibrary()
mkdir -p "$dir" \ mkdir -p "$dir" \
|| Panic "Unable to create directory: $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 fi


# Copy files # Copy files
@@ -188,10 +198,18 @@ function CreateExecutable()
mkdir -p "$dir" \ mkdir -p "$dir" \
|| Panic "Unable to create directory: $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 fi


# Copy files # Copy files
@@ -254,6 +272,15 @@ while [ $# -gt 0 ]; do
shift shift
;; ;;


"-M" | "--force-modules" )
if [ $# -lt 2 ]; then
Panic "Parameter $1 expects exactly one parameter!"
fi
CMakeModules="$2"
CMakeModulesForced="--force"
shift
;;

"-n" | "--nogit" ) "-n" | "--nogit" )
UseGit=0 UseGit=0
;; ;;


Загрузка…
Отмена
Сохранить