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.

57 lines
1.4 KiB

2 months ago
  1. cmake_minimum_required(VERSION 3.2)
  2. file(STRINGS defs.hh version REGEX "const version = \".*\";")
  3. string(REGEX MATCH "[0-9]+\\.[0-9]+" version "${version}")
  4. project(bliss VERSION ${version})
  5. # Use correct library extensions
  6. set(DYNAMIC_EXT ".so")
  7. set(STATIC_EXT ".a")
  8. if(APPLE)
  9. set(DYNAMIC_EXT ".dylib")
  10. set(STATIC_EXT ".a")
  11. set(CMAKE_MACOSX_RPATH 1)
  12. elseif (WIN32)
  13. set(DYNAMIC_EXT ".dll")
  14. set(STATIC_EXT ".lib")
  15. endif()
  16. # Compiler options
  17. set(CMAKE_CXX_FLAGS "-Wall --pedantic -O4 -fPIC")
  18. # Collect source files
  19. file(GLOB_RECURSE sources "*.cc")
  20. list(REMOVE_ITEM sources ${CMAKE_CURRENT_SOURCE_DIR}/bliss.cc)
  21. file(GLOB_RECURSE headers "*.h*")
  22. # Shared library
  23. add_library(libbliss_shared SHARED ${sources})
  24. set_target_properties(libbliss_shared PROPERTIES
  25. VERSION "${PROJECT_VERSION}"
  26. OUTPUT_NAME bliss
  27. )
  28. # Static library
  29. add_library(libbliss_static STATIC ${sources})
  30. set_target_properties(libbliss_static PROPERTIES
  31. VERSION "${PROJECT_VERSION}"
  32. OUTPUT_NAME bliss
  33. )
  34. # Install
  35. install(
  36. FILES ${headers}
  37. DESTINATION ${CMAKE_INSTALL_PREFIX}/include/bliss
  38. )
  39. install(
  40. TARGETS libbliss_shared
  41. RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
  42. LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
  43. ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
  44. )
  45. install(
  46. TARGETS libbliss_static
  47. RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
  48. LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
  49. ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
  50. )