adapt wc/r24255/#14395/ by Mitz Pettel <mitz@webkit.org>
[kdelibs.git] / kjs / CMakeLists.txt
blob3c2dc2ea8dcbb8768a96ab57f101435553cf6b1d
2 project(kjs)
4 add_subdirectory(tests)
6 # Conflict between KJS::HashTable and WTF::HashTable, due to "using namespace" of both namespaces.
7 KDE4_NO_ENABLE_FINAL(kjs)
9 # Configuration checks
10 include(FindThreads)
11 check_library_exists(pthread pthread_attr_get_np "" HAVE_PTHREAD_ATTR_GET_NP)
12 check_library_exists(pthread pthread_getattr_np "" HAVE_PTHREAD_GETATTR_NP)
13 check_include_files(float.h       HAVE_FLOAT_H)
14 check_include_files(sys/timeb.h   HAVE_SYS_TIMEB_H)
15 check_include_files(ieeefp.h      HAVE_IEEEFP_H)
16 check_include_files("pthread.h;pthread_np.h" HAVE_PTHREAD_NP_H)
17 check_include_files(valgrind/memcheck.h   HAVE_MEMCHECK_H)
19 MACRO_PUSH_REQUIRED_VARS()
20 if(NOT WIN32)
21     set(CMAKE_REQUIRED_LIBRARIES "-lm")
22 endif(NOT WIN32)
23 check_function_exists(_finite    HAVE_FUNC__FINITE)
24 check_function_exists(finite     HAVE_FUNC_FINITE)
25 check_function_exists(posix_memalign     HAVE_FUNC_POSIX_MEMALIGN)
26 check_symbol_exists(isnan   "math.h" HAVE_FUNC_ISNAN)
27 check_symbol_exists(isinf   "math.h" HAVE_FUNC_ISINF)
28 MACRO_POP_REQUIRED_VARS()
32 macro_optional_find_package(PCRE)
33 macro_bool_to_01(PCRE_FOUND HAVE_PCREPOSIX)
35 # Generate global.h
36 configure_file(global.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/global.h )
37 configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )
39 include_directories( ${CMAKE_SOURCE_DIR}/kjs ${CMAKE_SOURCE_DIR}/wtf ${KDEWIN32_INCLUDES} )
41 macro_log_feature(PCRE_FOUND "PCRE" "Perl Compatible Regular Expression" "www.pcre.org" FALSE "" "Provide better regular expression support in KJS.")
42 # the check for pcre is in kdelibs/CMakeLists.txt
43 if(PCRE_FOUND)
44    include_directories(${PCRE_INCLUDE_DIR})
45 else(PCRE_FOUND)
46 # if pcre is not installed, at least the posix regex.h has to be available
47    if(APPLE)
48       check_include_files("sys/types.h;regex.h" HAVE_REGEX_H)
49    else(APPLE)
50       check_include_files(regex.h HAVE_REGEX_H)
51    endif(APPLE)
52    if (NOT HAVE_REGEX_H)
53       message(FATAL_ERROR "Neither the PCRE regular expression library nor the POSIX regex.h header have been found. Consider installing PCRE.")
54    endif (NOT HAVE_REGEX_H)
55 endif(PCRE_FOUND)
57 ########### next target ###############
58 add_definitions(-DBUILDING_KDE__)
60 add_subdirectory( wtf )
62 set(CREATE_HASH_TABLE ${CMAKE_CURRENT_SOURCE_DIR}/create_hash_table )
64 macro(CREATE_LUT _srcs_LIST _in_FILE _out_FILE _dep_FILE)
66    add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_out_FILE}
67       COMMAND ${PERL_EXECUTABLE} ${CREATE_HASH_TABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${_in_FILE} -i > ${CMAKE_CURRENT_BINARY_DIR}/${_out_FILE}
68       DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_in_FILE} )
69    set( ${_srcs_LIST}  ${${_srcs_LIST}} ${CMAKE_CURRENT_BINARY_DIR}/${_out_FILE})
70 endmacro(CREATE_LUT)
72 create_lut(kjs_LIB_SRCS date_object.cpp date_object.lut.h date_object.cpp)
73 create_lut(kjs_LIB_SRCS number_object.cpp number_object.lut.h number_object.cpp)
74 create_lut(kjs_LIB_SRCS string_object.cpp string_object.lut.h string_object.cpp)
75 create_lut(kjs_LIB_SRCS array_object.cpp array_object.lut.h array_object.cpp)
76 create_lut(kjs_LIB_SRCS math_object.cpp math_object.lut.h math_object.cpp)
77 create_lut(kjs_LIB_SRCS regexp_object.cpp regexp_object.lut.h regexp_object.cpp)
78 create_lut(kjs_LIB_SRCS keywords.table lexer.lut.h lexer.cpp)
80 set(kjs_LIB_SRCS
81    ${kjs_LIB_SRCS}
82    ustring.cpp
83    date_object.cpp
84    collector.cpp
85    nodes.cpp
86    grammar.cpp
87    lexer.cpp
88    lookup.cpp
89    operations.cpp
90    regexp.cpp
91    function_object.cpp
92    string_object.cpp
93    bool_object.cpp
94    number_object.cpp
95    internal.cpp
96    Context.cpp
97    ExecState.cpp
98    Parser.cpp
99    array_object.cpp
100    math_object.cpp
101    object_object.cpp
102    regexp_object.cpp
103    error_object.cpp
104    function.cpp
105    debugger.cpp
106    value.cpp
107    list.cpp
108    object.cpp
109    interpreter.cpp
110    package.cpp
111    property_map.cpp
112    property_slot.cpp
113    nodes2string.cpp
114    identifier.cpp
115    scope_chain.cpp
116    dtoa.cpp
117    fpconst.cpp
118    JSLock.cpp
119    JSImmediate.cpp
120    PropertyNameArray.cpp
121    JSWrapperObject.cpp
122    CommonIdentifiers.cpp
123    semantic_checker.cpp
124    )
126 if (NOT DEFINED QT_ONLY)
127    set(KJSLIBNAME kjs)
128 else (NOT DEFINED QT_ONLY)
129    set(KJSLIBNAME qkjs)
130 endif (NOT DEFINED QT_ONLY)
133 kde4_add_library(${KJSLIBNAME} SHARED ${kjs_LIB_SRCS})
135 if(WIN32)
136    target_link_libraries(${KJSLIBNAME} ${KDEWIN32_LIBRARIES})
137 endif(WIN32) 
139 if(CMAKE_THREAD_LIBS_INIT)
140    target_link_libraries(${KJSLIBNAME} ${CMAKE_THREAD_LIBS_INIT})
141 endif(CMAKE_THREAD_LIBS_INIT)
143 if(UNIX)
144    target_link_libraries(${KJSLIBNAME} m)
145 endif(UNIX)
147 if(PCRE_FOUND)
148    target_link_libraries(${KJSLIBNAME} ${PCRE_LIBRARIES})
149 endif(PCRE_FOUND)
151 set_target_properties(${KJSLIBNAME} PROPERTIES VERSION ${GENERIC_LIB_VERSION} SOVERSION ${GENERIC_LIB_SOVERSION} )
152 install(TARGETS ${KJSLIBNAME} DESTINATION ${LIB_INSTALL_DIR})
154 ########### kjs - basic shell ###############
156 set(kjs_SRCS kjs.cpp)
158 # 'kjs_bin' because cmake doesn't like having a lib and app with the same name
159 kde4_add_executable(kjs_bin NOGUI ${kjs_SRCS})
161 set_target_properties(kjs_bin PROPERTIES OUTPUT_NAME kjs)
163 target_link_libraries(kjs_bin ${KJSLIBNAME})
165 install(TARGETS kjs_bin DESTINATION ${BIN_INSTALL_DIR})
167 ########### install files ###############
168 install( FILES
169     ExecState.h
170     JSImmediate.h
171     JSLock.h
172     JSType.h
173     PropertyNameArray.h
174     collector.h
175     completion.h
176     function.h
177     identifier.h
178     interpreter.h
179     list.h
180     lookup.h
181     object.h
182     operations.h
183     package.h
184     property_map.h
185     property_slot.h
186     protect.h
187     scope_chain.h
188     types.h
189     ustring.h
190     value.h
191     CommonIdentifiers.h
193     ${CMAKE_CURRENT_BINARY_DIR}/global.h
195     DESTINATION  ${INCLUDE_INSTALL_DIR}/kjs )