瀏覽代碼

* Fixed cmake files

master
bergmann 6 年之前
父節點
當前提交
abc2ee0604
共有 7 個檔案被更改,包括 91 行新增1 行删除
  1. +2
    -0
      .gitignore
  2. +3
    -0
      .gitmodules
  3. +3
    -1
      CMakeLists.txt
  4. +46
    -0
      cmake/Findcpputils.cmake
  5. +34
    -0
      cmake/Findmariadb.cmake
  6. +1
    -0
      cmake/modules
  7. +2
    -0
      test/CMakeLists.txt

+ 2
- 0
.gitignore 查看文件

@@ -0,0 +1,2 @@
.vscode/
build/

+ 3
- 0
.gitmodules 查看文件

@@ -0,0 +1,3 @@
[submodule "cmake/modules"]
path = cmake/modules
url = b3rgmann@git.bergmann89.de:cpp/CmakeModules.git

+ 3
- 1
CMakeLists.txt 查看文件

@@ -5,7 +5,9 @@ Include ( CTest )
If ( NOT CMAKE_BUILD_TYPE )
Set ( CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build!" FORCE )
EndIf ( NOT CMAKE_BUILD_TYPE )
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/../../../inc/cmake/")
Set ( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH}
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/"
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules" )

# Projects ########################################################################################



+ 46
- 0
cmake/Findcpputils.cmake 查看文件

@@ -0,0 +1,46 @@
Include ( ExternalProject )
Include ( FindPackageHandleStandardArgs )

Set ( CPPUTILS_PATH ${CMAKE_BINARY_DIR}/extern/cpputils )

If ( NOT TARGET cpputils_extern )
ExternalProject_Add ( cpputils_extern
PREFIX ${CPPUTILS_PATH}
TMP_DIR ${CPPUTILS_PATH}/tmp
STAMP_DIR ${CPPUTILS_PATH}/stamp
SOURCE_DIR ${CPPUTILS_PATH}/src
BINARY_DIR ${CPPUTILS_PATH}/build
INSTALL_DIR ${CPPUTILS_PATH}/install
GIT_REPOSITORY "https://git.bergmann89.de/cpp/cpputils.git"
GIT_TAG "master"
TEST_COMMAND make test
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>
-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MODULE_PATH=${CMAKE_MODULE_PATH})
EndIf ( )

Set ( CPPUTILS_LIBRARY ${CPPUTILS_PATH}/install/lib/libcpputils.so )
Set ( CPPUTILS_INCLUDE_DIR ${CPPUTILS_PATH}/install/include )
Set ( CPPUTILS_LIBRARIES ${CPPUTILS_LIBRARY} )
Set ( CPPUTILS_INCLUDE_DIRS ${CPPUTILS_INCLUDE_DIR} )

File ( MAKE_DIRECTORY ${CPPUTILS_INCLUDE_DIR} )

Find_Package_Handle_Standard_Args ( cpputils DEFAULT_MSG
CPPUTILS_LIBRARY
CPPUTILS_INCLUDE_DIR )

If ( NOT TARGET cpputils )
Add_Library ( cpputils SHARED IMPORTED )
Add_Dependencies ( cpputils cpputils_extern )
Set_Property ( TARGET cpputils
PROPERTY IMPORTED_LOCATION ${CPPUTILS_LIBRARY} )
Set_Property ( TARGET cpputils
PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${CPPUTILS_INCLUDE_DIRS} )
Install ( FILES ${CPPUTILS_LIBRARY} DESTINATION lib )
If ( CPPMARIADB_INSTALL_DEV_FILES )
Install ( DIRECTORY ${CPPUTILS_INCLUDE_DIR}/ DESTINATION include )
EndIf ( )
EndIf ( )

+ 34
- 0
cmake/Findmariadb.cmake 查看文件

@@ -0,0 +1,34 @@
Find_Library ( MARIADB_LIBRARY
NAMES mariadb mysql
PATH_SUFFIXES mariadb )

Find_File ( MARIADB_INCLUDE_DIR
NAMES mysql.h
PATH_SUFFIXES mariadb )

Get_Filename_Component ( MARIADB_INCLUDE_DIR
${MARIADB_INCLUDE_DIR}
DIRECTORY )

Include ( FindPackageHandleStandardArgs )

Find_Package_Handle_Standard_Args ( mariadb DEFAULT_MSG
MARIADB_LIBRARY
MARIADB_INCLUDE_DIR )

Mark_As_Advanced ( MARIADB_LIBRARY
MARIADB_LIBRARIES )

If ( MARIADB_FOUND )
Set ( MARIADB_LIBRARIES ${MARIADB_LIBRARY} )
Set ( MARIADB_INCLUDE_DIRS ${MARIADB_INCLUDE_DIR} )

If ( NOT TARGET mariadb )
Add_Library ( mariadb UNKNOWN IMPORTED )
Set_Property ( TARGET mariadb
PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${MARIADB_INCLUDE_DIRS}" )
Set_Property ( TARGET mariadb
APPEND
PROPERTY IMPORTED_LOCATION "${MARIADB_LIBRARY}")
EndIf ( )
EndIf ( )

+ 1
- 0
cmake/modules

@@ -0,0 +1 @@
Subproject commit b125a1a176ae0aada1cd2ec90919061d202dcea9

+ 2
- 0
test/CMakeLists.txt 查看文件

@@ -10,6 +10,8 @@ Set ( CMAKE_CXX_STANDARD 17 )
Set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${PEDANTIC_C_FLAGS}" )
Set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PEDANTIC_CXX_FLAGS}" )

Find_Package ( cpputils REQUIRED )

# Project: test_cppmariadb ########################################################################

Project ( test_cppmariadb )


Loading…
取消
儲存