Debian Codegraph @

examples/cmake/CMakeLists.txt

raw
1 #=============================================================================
2 # CMake project configuration file.
3 # Documentation: https://cmake.org/cmake/help/v3.6/
4 #=============================================================================
5 cmake_minimum_required(VERSION 3.6) # released in 2016
6 project(cmake_ecl_proj)
7 set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${CMAKE_SOURCE_DIR}/cmake/Modules/")
8
9 # Find ECL library. Refer to ./cmake/Modules/FindECL.cmake and
10 # https://cmake.org/cmake/help/v3.0/command/find_package.html
11 find_package(ECL REQUIRED)
12 include_directories(${ECL_INCLUDE_DIR})
13
14
15 # Put lisp sources and other files relevant for compilation here
16 # Any change of that files will trigger recompilation of `core-lisp` target
17 set(CORE_LISP_SOURCES
18 src/lisp/core-lisp.asd
19 src/lisp/core-lisp.lisp)
20
21 # Specify how `core-lisp` library is build by ECL
22 # The library is going to be built statically and moved to
23 # ${CMAKE_CURRENT_BINARY_DIR}.
24 #
25 # How to customize
26 # ================
27 # You can change "core-lisp" consistently to different name.
28 # Value of `:init-name` keyword must match extern declaration in C++ code.
29 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/core-lisp.a
30 COMMAND ${ECL_BIN_PATH} --norc
31 --eval '(require :asdf)'
32 # Remember to end path with / here. Notably ....src/lisp/, not ....src/lisp
33 --eval '(push \"${CMAKE_CURRENT_SOURCE_DIR}/src/lisp/\" asdf:*central-registry*)'
34 --eval '(asdf:make-build :core-lisp :type :static-library :move-here \"${CMAKE_CURRENT_BINARY_DIR}\" :init-name \"init_lib_CORE_LISP\")'
35 --eval '(quit)'
36 DEPENDS ${CORE_LISP_SOURCES})
37 # This goes in pair with `add_custom_command` above.
38 add_custom_target(core-lisp ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/core-lisp.a)
39
40 # Define executable to build. You can add other sources here.
41 # You may change "cmake_ecl" consistently into any name.
42 add_executable(cmake_ecl
43 src/cxx/main.cpp)
44
45 # Make cmake_ecl depend on core-lisp so it's going to be build before executable
46 add_dependencies(cmake_ecl core-lisp)
47
48 # Set what should be linked into `cmake_ecl` executable.
49 target_link_libraries(cmake_ecl
50 ${ECL_LIBRARIES}
51 ${CMAKE_CURRENT_BINARY_DIR}/core-lisp.a)
52
53 set_target_properties(cmake_ecl PROPERTIES
54 # Set c++ standard
55 CXX_STANDARD 17
56 # Do you want to use custom compiler extensions?
57 CXX_EXTENSION ON)
58