Browse Source

* Improved project structure

master
bergmann 4 years ago
parent
commit
20b98f4770
8 changed files with 37 additions and 19 deletions
  1. +1
    -1
      CMakeLists.txt
  2. +11
    -0
      projects/helloworld/cmake/helloworld-var.cmake
  3. +0
    -4
      projects/helloworld/test/CMakeLists.txt
  4. +6
    -3
      projects/libhelloworld/CMakeLists.txt
  5. +5
    -3
      projects/libhelloworld/cmake/libhelloworld-config.cmake
  6. +12
    -0
      projects/libhelloworld/cmake/libhelloworld-var.cmake
  7. +2
    -4
      projects/libhelloworld/src/CMakeLists.txt
  8. +0
    -4
      projects/libhelloworld/test/CMakeLists.txt

+ 1
- 1
CMakeLists.txt View File

@@ -14,7 +14,7 @@ If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" )
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/" )

EndIf ( )
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" )
If ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" )
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" )



+ 11
- 0
projects/helloworld/cmake/helloworld-var.cmake View File

@@ -15,3 +15,14 @@ Set ( CMAKE_C_STANDARD 11 )
Set ( CMAKE_CXX_STANDARD 17 )
Set ( CMAKE_C_STANDARD_REQUIRED ON )
Set ( CMAKE_CXX_STANDARD_REQUIRED ON )

# 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 )
EndIf ( )

+ 0
- 4
projects/helloworld/test/CMakeLists.txt View File

@@ -4,10 +4,6 @@ Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE
Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC )
Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS )

If ( HAS_PEDANTIC )
Pedantic_Apply_Flags ( ALL )
EndIf ( )

# Test ############################################################################################

Find_Package ( GTest )


+ 6
- 3
projects/libhelloworld/CMakeLists.txt View File

@@ -41,9 +41,12 @@ Configure_File ( "${CMAKE_CURRENT_SOURCE_DIR}/cmake/libhellow
@ONLY )

Set ( ConfigPackageLocation "${LIBHELLOWORLD_INSTALL_DIR_SHARE}/cmake" )
Install ( EXPORT libhelloworld
NAMESPACE libhelloworld::
DESTINATION ${ConfigPackageLocation} )
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"


+ 5
- 3
projects/libhelloworld/cmake/libhelloworld-config.cmake View File

@@ -1,8 +1,10 @@
# libhelloworld-config.cmake - package configuration file

Get_Filename_Component ( CURRENT_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH )
Include ( ${CURRENT_DIR}/libhelloworld.cmake )

Message ( WARNING "Please configure the dependencies of this package!" )
# Include ( CMakeFindDependencyMacro )
# Find_Dependency ( <dependency> )

Include ( FindPackageHandleStandardArgs )
Set ( ${CMAKE_FIND_PACKAGE_NAME}_CONFIG ${CMAKE_CURRENT_LIST_FILE} )
Find_Package_Handle_Standard_Args ( libhelloworld CONFIG_MODE )
Include ( "${CMAKE_CURRENT_LIST_DIR}/libhelloworld.cmake")

+ 12
- 0
projects/libhelloworld/cmake/libhelloworld-var.cmake View File

@@ -7,6 +7,7 @@ Set ( LIBHELLOWORLD_VERSION_SHORT "${LIBHELLOWORLD
Set ( LIBHELLOWORLD_VERSION "${LIBHELLOWORLD_VERSION_SHORT}.${LIBHELLOWORLD_VERSION_PATCH}.${LIBHELLOWORLD_VERSION_BUILD}" )
Set ( LIBHELLOWORLD_NAME "libhelloworld-${LIBHELLOWORLD_VERSION_SHORT}" )
Set ( LIBHELLOWORLD_OUTPUTNAME "helloworld" )
Message ( WARNING "Please configure the output name of protject!" )

# Install directories
Set ( LIBHELLOWORLD_INSTALL_DIR_INCLUDE "include/${LIBHELLOWORLD_NAME}" )
@@ -18,3 +19,14 @@ Set ( CMAKE_C_STANDARD 11 )
Set ( CMAKE_CXX_STANDARD 17 )
Set ( CMAKE_C_STANDARD_REQUIRED ON )
Set ( CMAKE_CXX_STANDARD_REQUIRED ON )

# 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 )
EndIf ( )

+ 2
- 4
projects/libhelloworld/src/CMakeLists.txt View File

@@ -39,11 +39,10 @@ Target_Include_Directories ( libhelloworld-objects

# Static Library ##################################################################################

Message ( WARNING "Please configure the output name of the static library target!" )
Add_Library ( libhelloworld-static STATIC $<TARGET_OBJECTS:libhelloworld-objects> )
Set_Target_Properties ( libhelloworld-static
PROPERTIES
OUTPUT_NAME "helloworld"
OUTPUT_NAME "${LIBHELLOWORLD_OUTPUTNAME}"
VERSION ${LIBHELLOWORLD_VERSION} )
Target_Include_Directories ( libhelloworld-static
PUBLIC
@@ -52,11 +51,10 @@ Target_Include_Directories ( libhelloworld-static

# Shared Library ##################################################################################

Message ( WARNING "Please configure the output name of the shared library target!" )
Add_Library ( libhelloworld-shared SHARED $<TARGET_OBJECTS:libhelloworld-objects> )
Set_Target_Properties ( libhelloworld-shared
PROPERTIES
OUTPUT_NAME "helloworld"
OUTPUT_NAME "${LIBHELLOWORLD_OUTPUTNAME}"
VERSION ${LIBHELLOWORLD_VERSION}
SOVERSION ${LIBHELLOWORLD_VERSION_SHORT} )
Target_Include_Directories ( libhelloworld-shared


+ 0
- 4
projects/libhelloworld/test/CMakeLists.txt View File

@@ -4,10 +4,6 @@ Include ( cotire OPTIONAL RESULT_VARIABLE HAS_COTIRE
Include ( pedantic OPTIONAL RESULT_VARIABLE HAS_PEDANTIC )
Include ( cmake_tests OPTIONAL RESULT_VARIABLE HAS_CMAKE_TESTS )

If ( HAS_PEDANTIC )
Pedantic_Apply_Flags ( ALL )
EndIf ( )

# Test ############################################################################################

Find_Package ( GTest )


Loading…
Cancel
Save