Use "modern" CMake facilities to manage includes and libs
[ginac.git] / ginsh / CMakeLists.txt
1
2 bison_target(ginsh_parser
3              ginsh_parser.ypp
4              ${CMAKE_CURRENT_BINARY_DIR}/ginsh_parser.cpp)
5 flex_target(ginsh_lexer
6             ginsh_lexer.lpp
7             ${CMAKE_CURRENT_BINARY_DIR}/ginsh_lexer.cpp)
8 add_flex_bison_dependency(ginsh_lexer ginsh_parser)
9
10 set(ginsh_SOURCES
11     ginsh_parser.cpp
12     ginsh_lexer.cpp
13 )
14
15 set(ginsh_HEADERS
16     ginsh_parser.hpp
17     ginsh.h
18     ginsh_fcn_help.h
19     ginsh_op_help.h
20 )
21
22 set(ginsh_DISTRIB
23     ${ginsh_SOURCES}
24     ${ginsh_HEADERS}
25     ginsh_parser.ypp
26     ginsh_lexer.lpp
27     ginsh.1.in
28     ginsh_fcn_help.py
29     ginsh_op_help.py
30 )
31 set(ginsh_include_directories ${CMAKE_CURRENT_BINARY_DIR}/.. ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR})
32 if (READLINE_FOUND)
33         set(ginsh_include_directories ${ginsh_include_directories} ${READLINE_INCLUDE_DIRS})
34 endif()
35
36 add_custom_command(
37         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ginsh_fcn_help.h
38         COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_fcn_help.py -o ginsh_fcn_help.h ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in
39         DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_fcn_help.py
40         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
41
42 add_custom_command(
43         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ginsh_op_help.h
44         COMMAND ${PYTHON} ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_op_help.py -o ginsh_op_help.h ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in
45         DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/ginsh.1.in ${CMAKE_CURRENT_SOURCE_DIR}/ginsh_op_help.py
46         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
47
48 add_custom_command(
49         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/ginsh_parser.hpp
50         DEPENDS ${BISON_ginsh_parser_OUTPUTS}
51         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
52
53 set(ginsh_extra_libs)
54 if (READLINE_FOUND)
55         set(ginsh_extra_libs ${READLINE_LIBRARIES})
56 endif()
57
58 add_executable(ginsh ${ginsh_SOURCES} ${ginsh_HEADERS})
59 target_link_libraries(ginsh ginac::ginac ${ginsh_extra_libs})
60 target_include_directories(ginsh PRIVATE ${ginsh_include_directories})
61 target_compile_definitions(ginsh PRIVATE HAVE_CONFIG_H)
62 install(TARGETS ginsh RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}")