[build] GiNaC can be built with CMake now.
[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.yy
10              ${CMAKE_CURRENT_BINARY_DIR}/ginsh_parser.cpp)
11 flex_target(ginsh_lexer
12             ginsh_lexer.ll
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.h
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.yy
32     ginsh_lexer.ll
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.h
55         COMMAND ${CMAKE_COMMAND} -E copy ginsh_parser.hpp ginsh_parser.h
56         DEPENDS ${BISON_ginsh_parser_OUTPUTS}
57         WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
58
59 set(ginsh_extra_libs)
60 if (READLINE_FOUND)
61         set(ginsh_extra_libs ${READLINE_LIBRARIES})
62 endif()
63
64 add_executable(ginsh ${ginsh_SOURCES} ${ginsh_HEADERS})
65 target_link_libraries(ginsh ginac ${ginsh_extra_libs})
66 install(TARGETS ginsh RUNTIME DESTINATION "${BIN_INSTALL_DIR}")