summaryrefslogtreecommitdiff
path: root/indra/lscript/lscript_compile/CMakeLists.txt
blob: 07662005b999ae39274f1ba6cd907870677244e0 (plain)
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# -*- cmake -*-

include(00-Common)
include(LLCommon)
include(LLMath)
include(LLMessage)
include(LLInventory)
include(LLPrimitive)
include(LScript)

include(FindCygwin)

find_program(FLEX flex
             "C:/Program Files/GnuWin32/bin"
             ${CYGWIN_INSTALL_PATH}/bin
             /bin
             /usr/bin
             /usr/local/bin
             )
mark_as_advanced(FLEX)

find_program(BISON bison
             "C:/Program Files/GnuWin32/bin"
             ${CYGWIN_INSTALL_PATH}/bin
             /bin
             /usr/bin
             /usr/local/bin
             )
mark_as_advanced(BISON)

find_program(M4 m4
             "C:/Program Files/GnuWin32/bin"
             ${CYGWIN_INSTALL_PATH}/bin
             /bin
             /usr/bin
             /usr/local/bin
             )
mark_as_advanced(M4)

include_directories(
    ${LLCOMMON_INCLUDE_DIRS}
    ${LLMATH_INCLUDE_DIRS}
    ${LLMESSAGE_INCLUDE_DIRS}
    ${LLINVENTORY_INCLUDE_DIRS}
    ${LLPRIMITIVE_INCLUDE_DIRS}
    ${LSCRIPT_INCLUDE_DIRS}
    )
include_directories(SYSTEM
    ${LLCOMMON_SYSTEM_INCLUDE_DIRS}
    )

set(lscript_generated_SOURCE_FILES
    indra.l.cpp
    indra.y.cpp
    )

set(lscript_compile_SOURCE_FILES
    lscript_alloc.cpp
    lscript_bytecode.cpp
    lscript_error.cpp
    lscript_heap.cpp
    lscript_resource.cpp
    lscript_scope.cpp
    lscript_tree.cpp
    lscript_typecheck.cpp
    )
    
set(lscript_compile_HEADER_FILES
    CMakeLists.txt

    indra.l
    indra.y

    ../lscript_alloc.h
    ../lscript_byteformat.h
    ../lscript_byteconvert.h
    ../lscript_http.h

    lscript_error.h
    lscript_bytecode.h
    lscript_heap.h
    lscript_resource.h
    lscript_scope.h
    lscript_tree.h
    lscript_typecheck.h
    )

set_source_files_properties(${lscript_compile_HEADER_FILES}
                            PROPERTIES HEADER_FILE_ONLY TRUE)

set_source_files_properties(${lscript_generated_SOURCE_FILES}
                            PROPERTIES HEADER_FILE_ONLY FALSE GENERATED TRUE)

list(APPEND lscript_compile_SOURCE_FILES ${lscript_generated_SOURCE_FILES} ${lscript_compile_HEADER_FILES})

add_custom_command(
    OUTPUT
      ${CMAKE_CURRENT_BINARY_DIR}/indra.l.cpp
    COMMAND ${FLEX}
    ARGS
      -P indra_
      -o${CMAKE_CURRENT_BINARY_DIR}/indra.l.cpp
      ${CMAKE_CURRENT_SOURCE_DIR}/indra.l
    DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/indra.l
    )

if (WINDOWS)
  set_source_files_properties(indra.l.cpp
                              PROPERTIES COMPILE_FLAGS /DYY_NO_UNISTD_H)
endif (WINDOWS)

if (WINDOWS)
  get_filename_component(M4_PATH ${M4} PATH)
  add_custom_command(
      OUTPUT
        ${CMAKE_CURRENT_BINARY_DIR}/indra.y.cpp
        ${CMAKE_CURRENT_BINARY_DIR}/indra.y.hpp
      COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/bison.bat
      ARGS
        ${BISON} ${M4_PATH}
        -p indra_
        -d -o ${CMAKE_CURRENT_BINARY_DIR}/indra.y.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/indra.y
      DEPENDS
        ${CMAKE_CURRENT_SOURCE_DIR}/bison.bat
        ${CMAKE_CURRENT_SOURCE_DIR}/indra.y
      )
  include_directories(${CMAKE_CURRENT_SOURCE_DIR}/windows)
else (WINDOWS)
  add_custom_command(
      OUTPUT
        ${CMAKE_CURRENT_BINARY_DIR}/indra.y.cpp
        ${CMAKE_CURRENT_BINARY_DIR}/indra.y.hpp
      COMMAND
        ${BISON}
      ARGS
        -p indra_
        -d -o ${CMAKE_CURRENT_BINARY_DIR}/indra.y.cpp
        ${CMAKE_CURRENT_SOURCE_DIR}/indra.y
      DEPENDS
        ${CMAKE_CURRENT_SOURCE_DIR}/indra.y
      )
endif (WINDOWS)

if (DARWIN)
  # Mac OS X 10.4 compatibility
  add_custom_command(
    OUTPUT
      ${CMAKE_CURRENT_BINARY_DIR}/indra.y.hpp
    COMMAND
      mv
      ${CMAKE_CURRENT_BINARY_DIR}/indra.y.cpp.h
      ${CMAKE_CURRENT_BINARY_DIR}/indra.y.hpp
    )
endif (DARWIN)

add_library (lscript_compile ${lscript_compile_SOURCE_FILES})