You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

56 lines
1.4 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
  1. cmake_minimum_required(VERSION 3.5)
  2. project(logging LANGUAGES C)
  3. message(STATUS ${CMAKE_SYSTEM_NAME})
  4. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake)
  5. include(require-git)
  6. #Targets
  7. set(SRCS src/logging.c)
  8. add_library(logging-headers INTERFACE)
  9. target_include_directories(logging-headers INTERFACE
  10. $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
  11. $<INSTALL_INTERFACE:include>
  12. )
  13. add_library(logging-shared SHARED ${SRCS})
  14. target_link_libraries(logging-shared PUBLIC logging-headers)
  15. add_library(logging-static STATIC ${SRCS})
  16. target_link_libraries(logging-static PUBLIC logging-headers)
  17. if(${CMAKE_BUILD_TYPE} MATCHES "Debug")
  18. add_executable(example example/main.c)
  19. target_link_libraries(example PRIVATE logging-shared)
  20. endif()
  21. #Install
  22. install(TARGETS logging-headers logging-static logging-shared EXPORT loggingTargets
  23. ARCHIVE DESTINATION lib
  24. LIBRARY DESTINATION lib
  25. RUNTIME DESTINATION bin
  26. INCLUDES DESTINATION include
  27. )
  28. install(DIRECTORY include/logging DESTINATION include)
  29. install(EXPORT loggingTargets
  30. FILE loggingTargets.cmake
  31. NAMESPACE logging::
  32. DESTINATION lib/cmake/logging
  33. )
  34. include(CMakePackageConfigHelpers)
  35. write_basic_package_version_file("loggingConfigVersion.cmake"
  36. VERSION ${logging_VERSION}
  37. COMPATIBILITY SameMajorVersion
  38. )
  39. install(
  40. FILES
  41. "cmake/loggingConfig.cmake"
  42. "${CMAKE_CURRENT_BINARY_DIR}/loggingConfigVersion.cmake"
  43. DESTINATION
  44. lib/cmake/logging
  45. )
  46. include(pack)