| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138 |
- cmake_minimum_required(VERSION 3.10)
- ################################################################################
- # This Top-level project is for a single Top-level library
- #
- # A single library
- # Unit tests for the library
- # A set of executables which use this library
- ################################################################################
- ################################################################################
- # Project name
- #
- # many targets will be created:
- # myProject::warnings
- # myProject:
- ################################################################################
- project( gul
- VERSION 1.0.0.0
- LANGUAGES CXX)
- ################################################################################
- include(.cmake/extras.cmake)
- option( ${PROJECT_NAME}_BUILD_UNIT_TESTS "Build the unit tests for this library" TRUE)
- option( ${PROJECT_NAME}_ENABLE_COVERAGE "Enable Coverage. After build, execute: make coverage" TRUE)
- option( ${PROJECT_NAME}_ENABLE_WARNINGS "Enable Strict Warnings" TRUE)
- option( ${PROJECT_NAME}_PACKAGE_INCLUDE_SOURCE "Include source files when building the package" TRUE)
- ################################################################################
- # Find all the packages we need
- #
- # Each module in the src/ folder can also define its own find_package
- # if they are meant to be private
- #
- ################################################################################
- #find_package(fmt REQUIRED)
- #find_package(glm REQUIRED)
- #find_package(glm REQUIRED)
- ################################################################################
- ################################################################################
- # Top level INTERFACE library which can be used to
- ################################################################################
- set(outName interface) # name of the library within the proje
- # Will create the target ${PROJECT_NAME}::${outName}
- set(PublicLinkedTargets "" ) # Any additional public targets you want to include
- #-------------------------------------------------------------------------------
- add_library( ${outName} INTERFACE )
- add_library( ${PROJECT_NAME}::${outName} ALIAS ${outName})
- target_compile_features( ${outName}
- INTERFACE
- cxx_std_20)
- target_compile_definitions( ${outName}
- INTERFACE
- CMAKE_SOURCE_DIR="${CMAKE_SOURCE_DIR}"
- CMAKE_BINARY_DIR="${CMAKE_BINARY_DIR}"
- )
- target_link_libraries( ${outName} INTERFACE ${PublicLinkedTargets})
- include(GNUInstallDirs)
- ################################################################################
- #####################################################
- # Macro get get all subdirectories
- #####################################################
- MACRO(SUBDIRLIST result curdir)
- FILE(GLOB children RELATIVE ${curdir} ${curdir}/*)
- SET(dirlist "")
- FOREACH(child ${children})
- IF(IS_DIRECTORY ${curdir}/${child})
- LIST(APPEND dirlist ${child})
- ENDIF()
- ENDFOREACH()
- SET(${result} ${dirlist})
- ENDMACRO()
- #####################################################
- #####################################################
- # Loop through all the subdirectories in the /src folder and
- # compile each of the folders into its own library
- #####################################################
- SUBDIRLIST(LIB_FOLDERS ${CMAKE_CURRENT_SOURCE_DIR}/src)
- FOREACH(subdir ${LIB_FOLDERS})
- if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/${subdir}/CMakeLists.txt")
- add_subdirectory("src/${subdir}")
- endif()
- ENDFOREACH()
- # enable testing on the root folder so that we can run ctest from it,
- # otherwise we will have to CD into each sub folder to run the unit tests
- enable_testing()
- #####################################################
- ## PACKAGE
- #####################################################
- SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
- SET(CPACK_PACKAGE_VENDOR ${PROJECT_NAME})
- SET(CPACK_PACKAGE_EXECUTABLES ${PROJECT_NAME};${PROJECT_NAME})
- SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "${PROJECT_NAME}")
- SET(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
- SET(CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
- SET(CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
- SET(CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
- SET(CPACK_PACKAGE_CONTACT "me")
- INCLUDE(InstallRequiredSystemLibraries)
- IF(WIN32 AND NOT UNIX)
- SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\${PROJECT_NAME}.exe")
- SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY}${PROJECT_NAME}")
- SET(CPACK_NSIS_MODIFY_PATH ON)
- ENDIF(WIN32 AND NOT UNIX)
- #####################################################
- INCLUDE(CPack)
- return()
|