CMakeLists.txt 2.7KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. cmake_minimum_required(VERSION 3.8)
  2. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/../cmake) # main (top) cmake dir
  3. set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) # project specific cmake dir
  4. # CMake useful variables
  5. set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
  6. set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
  7. set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
  8. # Set the name of your project here
  9. project("dbt-core")
  10. # Set the version number of your project here (format is MAJOR.MINOR.PATCHLEVEL - e.g. 1.0.0)
  11. set(VERSION_MAJOR "1")
  12. set(VERSION_MINOR "0")
  13. set(VERSION_PATCH "0")
  14. set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
  15. include(Common)
  16. if(DEFINED ENV{LLVM_HOME})
  17. find_path (LLVM_DIR LLVM-Config.cmake $ENV{LLVM_HOME}/lib/cmake/llvm)
  18. endif()
  19. find_package(LLVM REQUIRED CONFIG)
  20. set(LIB_SOURCES
  21. src/dbgsrvbase.cpp
  22. src/gdb_session.cpp
  23. src/jit_helper.cpp
  24. src/vm_base.cpp
  25. src/cmdhandler.cpp
  26. src/target_adapter_base.cpp
  27. src/encoderdecoder.cpp
  28. )
  29. # Define two variables in order not to repeat ourselves.
  30. set(LIBRARY_NAME dbt-core)
  31. # Define the library
  32. add_library(${LIBRARY_NAME} ${LIB_SOURCES})
  33. target_compile_definitions(${LIBRARY_NAME} PUBLIC ${LLVM_DEFINITIONS})
  34. target_include_directories(${LIBRARY_NAME} PUBLIC ${PROJECT_SOURCE_DIR}/incl)
  35. target_include_directories(${LIBRARY_NAME} PRIVATE ${LLVM_INCLUDE_DIRS})
  36. #set_target_properties(foo PROPERTIES LINK_FLAGS "My lib link flags")
  37. #set_target_properties(exe PROPERTIES LINK_FLAGS "My exe link flags")
  38. #target_link_options(${LIBRARY_NAME} BEFORE INTERFACE -Wl,-whole-archive INTERFACE -Wl,-no-whole-archive)
  39. target_link_libraries(${LIBRARY_NAME} PRIVATE scc-util)
  40. # Set the build version. It will be used in the name of the lib, with corresponding
  41. # symlinks created. SOVERSION could also be specified for api version.
  42. set_target_properties(${LIBRARY_NAME} PROPERTIES
  43. VERSION ${VERSION}
  44. FRAMEWORK FALSE
  45. PUBLIC_HEADER "${LIB_HEADERS}"
  46. )
  47. # Says how and where to install software
  48. # Targets:
  49. # * <prefix>/lib/<libraries>
  50. # * header location after install: <prefix>/include/<project>/*.h
  51. # * headers can be included by C++ code `#<project>/Bar.hpp>`
  52. install(TARGETS ${LIBRARY_NAME}
  53. EXPORT ${PROJECT_NAME}Targets # for downstream dependencies
  54. RUNTIME DESTINATION bin
  55. LIBRARY DESTINATION lib COMPONENT libs # shared lib
  56. ARCHIVE DESTINATION lib COMPONENT libs # static lib
  57. FRAMEWORK DESTINATION bin COMPONENT libs # for mac
  58. PUBLIC_HEADER DESTINATION include COMPONENT devel # headers for mac (note the different component -> different package)
  59. INCLUDES DESTINATION incl # headers
  60. )