CMakeLists.txt 1.2 KB

1234567891011121314151617181920212223242526272829303132
  1. cmake_minimum_required(VERSION 3.12)
  2. project("llama-cli-cmake-pkg" C CXX)
  3. set(TARGET llama-cli-cmake-pkg)
  4. find_package(Llama 0.0.1 REQUIRED)
  5. # Bake common functionality in with target. Because applications
  6. # using the relocatable Llama package should be outside of the
  7. # source tree, llama-cli-cmake-pkg pretends the dependencies are built-in.
  8. set(_common_path "${CMAKE_CURRENT_LIST_DIR}/../../common")
  9. add_library(common OBJECT)
  10. file(GLOB _common_files
  11. "${_common_path}/*.h"
  12. "${_common_path}/*.cpp"
  13. )
  14. target_sources(common PRIVATE ${_common_files})
  15. # If the common project was part of "llama-cli-cmake-pkg" the transient
  16. # defines would automatically be attached. Because the common func-
  17. # tionality is separate, but dependent upon the defines, it must be
  18. # explicitly extracted from the "llama" target.
  19. #
  20. get_target_property(_llama_transient_defines llama
  21. INTERFACE_COMPILE_DEFINITIONS)
  22. target_compile_definitions(common PRIVATE "${_llama_transient_defines}")
  23. add_executable(${TARGET} ${CMAKE_CURRENT_LIST_DIR}/../main/main.cpp)
  24. target_include_directories(${TARGET} PRIVATE ${_common_path})
  25. install(TARGETS ${TARGET} RUNTIME)
  26. target_link_libraries(${TARGET} PRIVATE common llama ${CMAKE_THREAD_LIBS_INIT})
  27. target_compile_features(${TARGET} PRIVATE cxx_std_17)