File: CMakeLists.txt

package info (click to toggle)
plplot 5.14.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 30,424 kB
  • sloc: ansic: 79,613; xml: 28,583; cpp: 20,037; ada: 19,456; tcl: 12,081; f90: 11,423; ml: 7,276; java: 6,863; python: 6,792; sh: 3,185; perl: 828; lisp: 75; makefile: 48; sed: 33; fortran: 5
file content (95 lines) | stat: -rw-r--r-- 3,363 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
# src_executable/CMakeLists.txt

if(BUILD_TEST)
  # Setup compilation of nominal source file (see below) by including
  # directory where test_ada library spec (*.ads) files reside.
  if(CORE_BUILD)
    include_directories(
      ${CMAKE_SOURCE_DIR}/src_lib
      )
  else(CORE_BUILD)
    include_directories(
      ${ADA_INCLUDE_DIR}
      )
  endif(CORE_BUILD)

  # Note due to limitations of the Ada language support for CMake, the
  # nominal source file for add_executable is compiled (which is why a
  # real file has to be specified), but otherwise it is ignored except
  # for its .adb suffix which identifies the Ada language.  The actual
  # source file name for the internal gnatmake command that creates
  # the executable is constructed from <TARGET>.adb.  Since no
  # directory can be specified from this construction (don't ask), you
  # must specify the directory of <TARGET>.adb with an -aI option (see
  # below).
  add_executable(hello hello.adb)

  # The first -aI option is required to find <TARGET>.adb (see above
  # comment). The second -aI option gives access to the test_ada
  # library spec (*.ads) files. The -aL option gives access to the
  # test_ada library *.ali files.  (For the CORE_BUILD case, that
  # location currently works but is probably not guaranteed
  # indefinitely for future versions of CMake.)

  if(CORE_BUILD)
    set_target_properties(
      hello
      PROPERTIES
      LINK_FLAGS
      "\"-aI${CMAKE_CURRENT_SOURCE_DIR}\" \"-aI${CMAKE_SOURCE_DIR}/src_lib\" \"-aL${CMAKE_BINARY_DIR}/src_lib/CMakeFiles/hello_1.dir\""
      )
  else(CORE_BUILD)
    set_target_properties(
      hello
      PROPERTIES
      LINK_FLAGS
      "\"-aI${CMAKE_CURRENT_SOURCE_DIR}\" \"-aI${ADA_INCLUDE_DIR}\" \"-aL${ADA_LIB_DIR}\""
      )
  endif(CORE_BUILD)
  target_link_libraries(hello hello_1)

  # CMake assumes compilation results only in object files being generated.
  # However, gnatmake generates both object files and *.ali (Ada library
  # information) files so it doesn't intrinsically know how to clean those
  # additional *.ali files.
  # Here is a workaround for this fundamental CMake limitation.

  # Add generated .ali file and "extra" generated pair of .ali and .o files
  # to the list of additional files to be removed by make clean

  set_directory_properties(
    PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
    "${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/hello.dir/hello.ali;${CMAKE_CURRENT_BINARY_DIR}/hello.ali;${CMAKE_CURRENT_BINARY_DIR}/hello.o"
    )

  # configure file to compare with output of hello executable.
  file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/compare_hello.out
    "hello, world"
    )

  # Add test_noninteractive custom_target to compare hello executable output
  # with file configure above.
  add_custom_command(
    OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/hello.out
    COMMAND
    hello
    COMMAND
    ${CMP_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/hello.out ${CMAKE_CURRENT_BINARY_DIR}/compare_hello.out
    DEPENDS
    hello
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
    VERBATIM
    )
  add_custom_target(test_noninteractive
    DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/hello.out
    )

endif(BUILD_TEST)

if(CORE_BUILD)
  install(FILES
    ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt
    ${CMAKE_CURRENT_SOURCE_DIR}/hello.adb
    DESTINATION ${DATA_DIR}/examples/ada
    )
endif(CORE_BUILD)