Warning, /frameworks/kjs/src/kjs/CMakeLists.txt is written in an unsupported language. File is not indexed.

0001 if(NOT WIN32)
0002     set(CMAKE_REQUIRED_LIBRARIES "-lm")
0003 endif()
0004 
0005 set(HAVE_PCREPOSIX ${PCRE_FOUND})
0006 
0007 # Configuration checks
0008 include(ConfigureChecks.cmake)
0009 # Generate global.h
0010 check_cxx_compiler_flag(-fvisibility=hidden __KDE_HAVE_GCC_VISIBILITY)
0011 configure_file(global.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/global.h )
0012 
0013 # the check for pcre is in ../CMakeLists.txt
0014 if(PCRE_FOUND AND NOT KJS_FORCE_DISABLE_PCRE)
0015    include_directories(${PCRE_INCLUDE_DIR})
0016 
0017    # tell check_symbol_exists to -I pcre dirs.
0018    include(CMakePushCheckState)
0019    cmake_push_check_state()
0020    set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${PCRE_INCLUDE_DIR})
0021 
0022    check_symbol_exists(PCRE_CONFIG_UTF8 "pcre.h" HAVE_PCRE_UTF8)
0023    check_symbol_exists(PCRE_CONFIG_STACKRECURSE "pcre.h" HAVE_PCRE_STACK)
0024 
0025    cmake_pop_check_state()
0026 
0027    # Even though we "support" non-PCRE builds, if we build PCRE, we want a version
0028    # recent enough, and we don't want to fallback to a completely crippled
0029    # POSIX code just like that.
0030    if (NOT HAVE_PCRE_UTF8  OR NOT  HAVE_PCRE_STACK)
0031       message(FATAL_ERROR "Your libPCRE is too old. KJS requires at least PCRE4.5")
0032    endif ()
0033 
0034 else ()
0035    # if we're here, either PCRE support is disabled, or it's not found...
0036    # it better be disabled.
0037    if (NOT KJS_FORCE_DISABLE_PCRE)
0038         message(FATAL_ERROR "The PCRE regular expression library has not been found. KJS requires PCRE >= 4.5 to function properly. If you for some reason can not install it, you can force a build with POSIX regex.h by passing -DKJS_FORCE_DISABLE_PCRE=true to cmake. However, be advised that it'll result in many websites breaking")
0039    endif ()
0040    # if pcre is not installed or disabled, at least the posix regex.h has to be available
0041    if(APPLE)
0042       check_include_files("sys/types.h;regex.h" HAVE_REGEX_H)
0043    else()
0044       check_include_files(regex.h HAVE_REGEX_H)
0045    endif()
0046    if (NOT HAVE_REGEX_H)
0047       message(FATAL_ERROR "Neither the PCRE regular expression library nor the POSIX regex.h header have been found. Consider installing PCRE.")
0048    endif ()
0049 endif()
0050 
0051 # The crosscompiling parts are commented out on purpose. Alex
0052 # if (CMAKE_CROSSCOMPILING)
0053 #    set(IMPORT_ICEMAKER_EXECUTABLE "${KDE_HOST_TOOLS_PATH}/ImportIcemakerExecutable.cmake" CACHE FILEPATH "Point it to the export file of icemaker from a native build")
0054 #    include(${IMPORT_ICEMAKER_EXECUTABLE})
0055 #    set(ICEMAKER_EXECUTABLE icemaker)
0056 # else ()
0057 
0058    ########### icemaker, generates some tables for kjs/frostbyte ###############
0059    set(icemaker_SRCS
0060        bytecode/generator/tablebuilder.cpp
0061        bytecode/generator/types.cpp
0062        bytecode/generator/codeprinter.cpp
0063        bytecode/generator/driver.cpp
0064        bytecode/generator/lexer.cpp
0065        bytecode/generator/parser.cpp
0066       )
0067    add_executable(icemaker ${icemaker_SRCS})
0068    ecm_mark_nongui_executable(icemaker)
0069    target_include_directories(icemaker PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}/..")
0070 
0071    # get the name of the generated wrapper script (which sets up LD_LIBRARY_PATH)
0072    #get_target_property(ICEMAKER_EXECUTABLE icemaker WRAPPER_SCRIPT)
0073    #get_target_property(ICEMAKER_EXECUTABLE_DIR icemaker RUNTIME_OUTPUT_DIRECTORY)
0074    set(ICEMAKER_EXECUTABLE icemaker)
0075 
0076 #    export(TARGETS icemaker FILE ${CMAKE_BINARY_DIR}/ImportIcemakerExecutable.cmake)
0077 # endif ()
0078 
0079 # and the custom command
0080 add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/opcodes.h ${CMAKE_CURRENT_BINARY_DIR}/opcodes.cpp
0081     ${CMAKE_CURRENT_BINARY_DIR}/machine.cpp
0082   COMMAND ${ICEMAKER_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/bytecode
0083   DEPENDS icemaker ${CMAKE_CURRENT_SOURCE_DIR}/bytecode/codes.def
0084           ${CMAKE_CURRENT_SOURCE_DIR}/bytecode/opcodes.cpp.in
0085           ${CMAKE_CURRENT_SOURCE_DIR}/bytecode/opcodes.h.in
0086           ${CMAKE_CURRENT_SOURCE_DIR}/bytecode/machine.cpp.in
0087 )
0088 set_source_files_properties(
0089    ${CMAKE_CURRENT_BINARY_DIR}/opcodes.cpp
0090    ${CMAKE_CURRENT_BINARY_DIR}/machine.cpp
0091    PROPERTIES SKIP_AUTOMOC TRUE
0092 )
0093 
0094 ########### next target ###############
0095 
0096 # We don't want -pedantic/--pedantic for KJS since we want to use GCC extension when available
0097 string(REPLACE "--pedantic" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
0098 string(REPLACE "-pedantic" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
0099 
0100 add_definitions(-DBUILDING_KDE__)
0101 
0102 set(CREATE_HASH_TABLE ${CMAKE_CURRENT_SOURCE_DIR}/create_hash_table )
0103 
0104 macro(CREATE_LUT _srcs_LIST _in_FILE _out_FILE _dep_FILE)
0105 
0106    set(_out_FILE "${CMAKE_CURRENT_BINARY_DIR}/${_out_FILE}")
0107    add_custom_command(OUTPUT ${_out_FILE}
0108       COMMAND ${PERL_EXECUTABLE} ${CREATE_HASH_TABLE} ${CMAKE_CURRENT_SOURCE_DIR}/${_in_FILE} -i > ${_out_FILE}
0109       DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${_in_FILE} )
0110 
0111    set_source_files_properties(${_out_FILE} PROPERTIES SKIP_AUTOMOC TRUE)
0112 
0113    set( ${_srcs_LIST}  ${${_srcs_LIST}} ${_out_FILE})
0114 endmacro(CREATE_LUT)
0115 
0116 create_lut(kjs_LIB_SRCS date_object.cpp date_object.lut.h date_object.cpp)
0117 create_lut(kjs_LIB_SRCS number_object.cpp number_object.lut.h number_object.cpp)
0118 create_lut(kjs_LIB_SRCS string_object.cpp string_object.lut.h string_object.cpp)
0119 create_lut(kjs_LIB_SRCS array_object.cpp array_object.lut.h array_object.cpp)
0120 create_lut(kjs_LIB_SRCS math_object.cpp math_object.lut.h math_object.cpp)
0121 create_lut(kjs_LIB_SRCS json_object.cpp json_object.lut.h json_object.cpp)
0122 create_lut(kjs_LIB_SRCS regexp_object.cpp regexp_object.lut.h regexp_object.cpp)
0123 create_lut(kjs_LIB_SRCS keywords.table lexer.lut.h lexer.cpp)
0124 
0125 set(kjs_LIB_SRCS
0126    ${kjs_LIB_SRCS}
0127    ustring.cpp
0128    date_object.cpp
0129    collector.cpp
0130    nodes.cpp
0131    grammar.cpp
0132    lexer.cpp
0133    lookup.cpp
0134    operations.cpp
0135    regexp.cpp
0136    function_object.cpp
0137    string_object.cpp
0138    bool_object.cpp
0139    number_object.cpp
0140    internal.cpp
0141    ExecState.cpp
0142    Parser.cpp
0143    array_object.cpp
0144    array_instance.cpp
0145    math_object.cpp
0146    object_object.cpp
0147    regexp_object.cpp
0148    error_object.cpp
0149    function.cpp
0150    debugger.cpp
0151    value.cpp
0152    list.cpp
0153    object.cpp
0154    interpreter.cpp
0155    package.cpp
0156    property_map.cpp
0157    property_slot.cpp
0158    nodes2string.cpp
0159    identifier.cpp
0160    scope_chain.cpp
0161    dtoa.cpp
0162    fpconst.cpp
0163    JSLock.cpp
0164    JSImmediate.cpp
0165    PropertyNameArray.cpp
0166    JSWrapperObject.cpp
0167    CommonIdentifiers.cpp
0168    JSVariableObject.cpp
0169    ${CMAKE_CURRENT_BINARY_DIR}/opcodes.cpp
0170    ${CMAKE_CURRENT_BINARY_DIR}/machine.cpp
0171    nodes2bytecode.cpp
0172    CompileState.cpp
0173    jsonlexer.cpp
0174    json_object.cpp
0175    jsonstringify.cpp
0176    propertydescriptor.cpp
0177    )
0178 
0179 
0180 add_library(KF5JS ${kjs_LIB_SRCS})
0181 add_library(KF5::JS ALIAS KF5JS)
0182 
0183 set(kjs_INCLUDES
0184   ${CMAKE_CURRENT_BINARY_DIR}/..
0185   ${CMAKE_CURRENT_SOURCE_DIR}/..
0186   ${CMAKE_CURRENT_BINARY_DIR}/../..
0187   ${CMAKE_CURRENT_SOURCE_DIR}/../wtf
0188 )
0189 
0190 target_include_directories(KF5JS PUBLIC "$<BUILD_INTERFACE:${kjs_INCLUDES}>")
0191 
0192 if(CMAKE_THREAD_LIBS_INIT)
0193    target_link_libraries(KF5JS PRIVATE ${CMAKE_THREAD_LIBS_INIT})
0194 endif()
0195 
0196 if(UNIX)
0197    target_link_libraries(KF5JS PRIVATE m)
0198 endif()
0199 
0200 if(PCRE_FOUND)
0201    target_link_libraries(KF5JS PRIVATE ${PCRE_LIBRARIES})
0202 endif()
0203 target_compile_definitions(KF5JS PRIVATE MAKE_KJS_LIB=1)
0204 
0205 set_target_properties(KF5JS PROPERTIES VERSION ${KJS_VERSION}
0206                                        SOVERSION ${KJS_SOVERSION}
0207                                        EXPORT_NAME JS
0208 )
0209 install(TARGETS KF5JS EXPORT KF5JSTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
0210 
0211 ########### kjs - basic shell ###############
0212 
0213 set(kjs_SRCS kjs.cpp)
0214 
0215 # 'kjs_bin' because cmake doesn't like having a lib and app with the same name
0216 # This is a developer tool, not intended for normal user installs
0217 add_executable(kjs_bin ${kjs_SRCS})
0218 ecm_mark_nongui_executable(kjs_bin)
0219 set_target_properties(kjs_bin PROPERTIES RUNTIME_OUTPUT_NAME kjs5)
0220 
0221 target_link_libraries(kjs_bin KF5JS)
0222 
0223 install(TARGETS kjs_bin ${KF5_INSTALL_TARGETS_DEFAULT_ARGS})
0224 
0225 ########### KDE-specific API ##############
0226 
0227 add_subdirectory(api)
0228 
0229 ########### install files ###############
0230 # install( FILES
0231 #     ExecState.h
0232 #     JSImmediate.h
0233 #     JSLock.h
0234 #     JSType.h
0235 #     PropertyNameArray.h
0236 #     collector.h
0237 #     completion.h
0238 #     function.h
0239 #     identifier.h
0240 #     interpreter.h
0241 #     list.h
0242 #     lookup.h
0243 #     object.h
0244 #     operations.h
0245 #     package.h
0246 #     property_map.h
0247 #     property_slot.h
0248 #     protect.h
0249 #     scope_chain.h
0250 #     types.h
0251 #     ustring.h
0252 #     value.h
0253 #     CommonIdentifiers.h
0254 #
0255 #     ${CMAKE_CURRENT_BINARY_DIR}/global.h
0256 #
0257 #     DESTINATION  ${KDE_INSTALL_INCLUDEDIR_KF5}/kjs COMPONENT Devel )
0258 install(FILES
0259   array_instance.h
0260   array_object.h
0261   bool_object.h
0262   collector.h
0263   CommonIdentifiers.h
0264   commonunicode.h
0265   CompileState.h
0266   completion.h
0267   context.h
0268   date_object.h
0269   debugger.h
0270   dtoa.h
0271   error_object.h
0272   ExecState.h
0273   function.h
0274   function_object.h
0275   grammar.h
0276   identifier.h
0277   internal.h
0278   interpreter.h
0279   JSImmediate.h
0280   JSLock.h
0281   jsonlexer.h
0282   json_object.h
0283   jsonstringify.h
0284   JSType.h
0285   JSVariableObject.h
0286   JSWrapperObject.h
0287   lexer.h
0288   list.h
0289   LocalStorage.h
0290   lookup.h
0291   makenodes.h
0292   math_object.h
0293   nodes2bytecode.h
0294   nodes.h
0295   number_object.h
0296   object.h
0297   object_object.h
0298   operations.h
0299   package.h
0300   Parser.h
0301   propertydescriptor.h
0302   property_map.h
0303   PropertyNameArray.h
0304   property_slot.h
0305   protect.h
0306   regexp.h
0307   regexp_object.h
0308   SavedBuiltins.h
0309   scope_chain.h
0310   scriptfunction.h
0311   string_object.h
0312   SymbolTable.h
0313   types.h
0314   ustring.h
0315   value.h
0316   ${CMAKE_CURRENT_BINARY_DIR}/global.h
0317   DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/kjs
0318   COMPONENT Devel
0319 )
0320 
0321 install(FILES create_hash_table DESTINATION ${KDE_INSTALL_DATADIR_KF5}/kjs/ )
0322 
0323 include(ECMGeneratePriFile)
0324 ecm_generate_pri_file(BASE_NAME KJS LIB_NAME KF5JS DEPS "core" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/KJS)
0325 install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR})