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