|
1 |
| -# Copyright (C) 2011 - 2019 Red Hat, Inc. |
| 1 | +# Copyright (C) 2011 - 2020 Red Hat, Inc. |
2 | 2 | #
|
3 | 3 | # This file is part of csdiff.
|
4 | 4 | #
|
|
18 | 18 | cmake_minimum_required(VERSION 2.8)
|
19 | 19 | project(csdiff CXX)
|
20 | 20 | enable_testing()
|
21 |
| -add_definitions(-Wall -Wextra -fPIC -std=c++11) |
22 | 21 |
|
23 |
| -# cslib.a |
24 |
| -add_library(cs STATIC |
25 |
| - abstract-filter.cc |
26 |
| - abstract-parser.cc |
27 |
| - abstract-writer.cc |
28 |
| - color.cc |
29 |
| - csdiff-core.cc |
30 |
| - csfilter.cc |
31 |
| - csparser.cc |
32 |
| - cswriter.cc |
33 |
| - cwe-mapper.cc |
34 |
| - deflookup.cc |
35 |
| - defqueue.cc |
36 |
| - gcc-parser.cc |
37 |
| - html-writer.cc |
38 |
| - instream.cc |
39 |
| - json-parser.cc |
40 |
| - json-writer.cc |
41 |
| - parser-common.cc |
42 |
| - shared-string.cc |
43 |
| - version.cc |
44 |
| -) |
| 22 | +# C/C++ sources |
| 23 | +add_subdirectory(src) |
45 | 24 |
|
46 |
| -# link cslib.a and boost libraries |
47 |
| -find_library(BOOST_REGEX boost_regex REQUIRED) |
48 |
| -find_library(BOOST_PROGRAM_OPTIONS boost_program_options REQUIRED) |
49 |
| -link_libraries(cs |
50 |
| - boost_regex |
51 |
| - boost_program_options) |
52 |
| - |
53 |
| -# the list of executables |
54 |
| -add_executable(csdiff csdiff.cc) |
55 |
| -add_executable(csgrep csgrep.cc) |
56 |
| -add_executable(cshtml cshtml.cc) |
57 |
| -add_executable(cslinker cslinker.cc) |
58 |
| -add_executable(cssort cssort.cc) |
59 |
| - |
60 |
| -# experimental |
61 |
| -add_executable(cstrans-df-run cstrans-df-run.cc) |
62 |
| -target_link_libraries(cstrans-df-run |
63 |
| - boost_filesystem |
64 |
| - boost_system) |
65 |
| - |
66 |
| -# load regression tests |
| 25 | +# regression tests |
67 | 26 | add_subdirectory(tests)
|
68 |
| - |
69 |
| -# declare what 'make install' should install |
70 |
| -install(TARGETS |
71 |
| - csdiff |
72 |
| - csgrep |
73 |
| - cshtml |
74 |
| - cslinker |
75 |
| - cssort |
76 |
| - cstrans-df-run |
77 |
| - DESTINATION bin) |
78 |
| - |
79 |
| -# pycsdiff - python binding of csdiff |
80 |
| -option(BUILD_PYCSDIFF "Set to ON to enable python binding" ON) |
81 |
| -if (BUILD_PYCSDIFF) |
82 |
| - set(BOOST_PYTHON_LIB_NAME "boost_python" |
83 |
| - CACHE STRING "Name of the boost_python library") |
84 |
| - |
85 |
| - # boost_python3 is used on Fedora 29. |
86 |
| - # boost_python38 is used on Fedora 31. |
87 |
| - # boost_python-3.x is used on Gentoo Linux. |
88 |
| - find_library(BOOST_PYTHON NAMES ${BOOST_PYTHON_LIB_NAME} |
89 |
| - boost_python3 |
90 |
| - boost_python39 boost_python-3.9 |
91 |
| - boost_python38 boost_python-3.8 |
92 |
| - boost_python37 boost_python-3.7 |
93 |
| - boost_python36 boost_python-3.6 |
94 |
| - boost_python35 boost_python-3.5) |
95 |
| - |
96 |
| - message(STATUS "BOOST_PYTHON: ${BOOST_PYTHON}") |
97 |
| - |
98 |
| - # query PYTHON_INCLUDE_DIR |
99 |
| - find_package(PythonInterp REQUIRED) |
100 |
| - find_package(PythonLibs REQUIRED) |
101 |
| - message(STATUS "PYTHON_INCLUDE_DIR: ${PYTHON_INCLUDE_DIR}") |
102 |
| - if(NOT EXISTS "${PYTHON_INCLUDE_DIR}/pyconfig.h") |
103 |
| - message(FATAL_ERROR " |
104 |
| -${PYTHON_INCLUDE_DIR}/pyconfig.h does not exits") |
105 |
| - endif() |
106 |
| - |
107 |
| - # query PYTHON_SITEARCH |
108 |
| - execute_process(COMMAND ${PYTHON_EXECUTABLE} |
109 |
| - -c "from distutils.sysconfig import get_python_lib |
110 |
| -print(get_python_lib(1))" |
111 |
| - RESULT_VARIABLE PYTHON_SITEARCH_STATUS |
112 |
| - OUTPUT_VARIABLE PYTHON_SITEARCH |
113 |
| - OUTPUT_STRIP_TRAILING_WHITESPACE) |
114 |
| - if("${PYTHON_SITEARCH_STATUS}" EQUAL 0) |
115 |
| - message(STATUS "PYTHON_SITEARCH: ${PYTHON_SITEARCH}") |
116 |
| - else() |
117 |
| - message(FATAL_ERROR " |
118 |
| -failed to query PYTHON_SITEARCH") |
119 |
| - endif() |
120 |
| - |
121 |
| - message(STATUS "python binding enabled, the pycsdiff module will be built!") |
122 |
| - add_library(pycsdiff SHARED pycsdiff.cc) |
123 |
| - set_target_properties(pycsdiff PROPERTIES |
124 |
| - COMPILE_FLAGS "-I${PYTHON_INCLUDE_DIR}" |
125 |
| - PREFIX "") |
126 |
| - target_link_libraries(pycsdiff ${BOOST_PYTHON}) |
127 |
| - install(TARGETS pycsdiff DESTINATION ${PYTHON_SITEARCH}) |
128 |
| -endif() |
129 |
| - |
130 |
| -# macro to generate a man page from the corresponding binary |
131 |
| -macro(create_manpage BINARY) |
132 |
| - set(H2M_INCLUDE "${CMAKE_CURRENT_SOURCE_DIR}/${BINARY}.h2m") |
133 |
| - if(EXISTS "${H2M_INCLUDE}") |
134 |
| - set(H2M_ARGS --include ${H2M_INCLUDE}) |
135 |
| - else() |
136 |
| - set(H2M_ARGS "") |
137 |
| - endif() |
138 |
| - add_custom_command(TARGET ${BINARY} POST_BUILD |
139 |
| - COMMAND ${HELP2MAN} --no-info --section 1 ${H2M_ARGS} |
140 |
| - ${CMAKE_CURRENT_BINARY_DIR}/${BINARY} |
141 |
| - > ${BINARY}.1 || rm -f ${BINARY}.1 |
142 |
| - COMMENT "Generating ${BINARY} man page" |
143 |
| - VERBATIM) |
144 |
| - install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${BINARY}.1 |
145 |
| - DESTINATION share/man/man1) |
146 |
| -endmacro(create_manpage) |
147 |
| - |
148 |
| -# generate man pages using help2man if available |
149 |
| -find_program(HELP2MAN help2man) |
150 |
| -if(HELP2MAN) |
151 |
| - create_manpage(csdiff) |
152 |
| - create_manpage(csgrep) |
153 |
| - create_manpage(cshtml) |
154 |
| - create_manpage(cslinker) |
155 |
| - create_manpage(cssort) |
156 |
| - create_manpage(cstrans-df-run) |
157 |
| -endif() |
0 commit comments