Statistics
| Branch: | Revision:

root / CMakeLists.txt @ 26df3e66

History | View | Annotate | Download (3.8 kB)

1
# WebODF is mostly a JavaScript project. CMake needs to know about the C++ parts
2
project (WebODF C CXX)
3
# version 2.8.2 is needed to have support for zip files in external projects
4
cmake_minimum_required(VERSION 2.8.2)
5
6
# At this point, the version number that is used throughout is defined
7
set(WEBODF_VERSION 0.3.0)
8
9
# This makefile 'compiles' WebODF using various tools, instruments the code and
10
# builds and packages programs that use WebODF.
11
12
# Find installed dependencies
13
find_package(Qt4 4.7.0 COMPONENTS QtCore QtGui QtXml QtNetwork QtWebKit)
14
if (NOT QT4_FOUND)
15
  message(WARNING "Qt4 with modules QtCore QtGui QtXml QtNetwork QtWebKit was not found. qtjsruntime will no be built.")
16
endif (NOT QT4_FOUND)
17
18
# java runtime is needed for Closure Compiler
19
find_package(Java COMPONENTS Runtime)
20
21
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
22
  message(FATAL_ERROR "Compiling in the source directortory is not supported. Use for example 'mkdir build; cd build; cmake ..'.")
23
endif (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
24
25
# Tools must be obtained to work with:
26
include (ExternalProject)
27
28
if(Java_JAVA_EXECUTABLE)
29
    # Closure Compiler
30
    ExternalProject_Add(
31
        ClosureCompiler
32
        URL "http://closure-compiler.googlecode.com/files/compiler-20120123.tar.gz"
33
        URL_MD5 1e23c299c8a8d0fa1f812ea8743bddcc
34
        CONFIGURE_COMMAND ""
35
        BUILD_COMMAND ""
36
        INSTALL_COMMAND ""
37
    )
38
    set(CLOSURE_JAR ${CMAKE_BINARY_DIR}/ClosureCompiler-prefix/src/ClosureCompiler/compiler.jar)
39
endif(Java_JAVA_EXECUTABLE)
40
41
# Rhino
42
if(Java_JAVA_EXECUTABLE)
43
    ExternalProject_Add(
44
        Rhino
45
        URL "ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino1_7R3.zip"
46
        URL_MD5 99d94103662a8d0b571e247a77432ac5
47
        CONFIGURE_COMMAND ""
48
        BUILD_COMMAND ""
49
        INSTALL_COMMAND ""
50
    )
51
    set(RHINO ${CMAKE_BINARY_DIR}/Rhino-prefix/src/Rhino/js.jar)
52
endif(Java_JAVA_EXECUTABLE)
53
54
# JSDoc
55
ExternalProject_Add(
56
    JsDoc
57
    URL "http://jsdoc-toolkit.googlecode.com/files/jsdoc_toolkit-2.4.0.zip"
58
    URL_MD5 a8f78f5ecd24b54501147b2af341a231
59
    CONFIGURE_COMMAND ""
60
    BUILD_COMMAND ""
61
    INSTALL_COMMAND ""
62
)
63
set(JSDOCDIR ${CMAKE_BINARY_DIR}/JsDoc-prefix/src/JsDoc/jsdoc-toolkit)
64
65
# Node.JS
66
ExternalProject_Add(
67
    NodeJS
68
    URL "http://nodejs.org/dist/v0.6.9/node-v0.6.9.tar.gz"
69
    URL_MD5 c2d2aee123a141ba8431855f1d9c8200
70
    CONFIGURE_COMMAND "./configure"
71
    BUILD_IN_SOURCE 1
72
    INSTALL_COMMAND ""
73
)
74
set(NODE ${CMAKE_BINARY_DIR}/NodeJS-prefix/src/NodeJS/out/Release/node)
75
76
# JSCoverage
77
ExternalProject_Add(
78
    JSCoverage
79
    URL "http://siliconforks.com/jscoverage/download/jscoverage-0.5.1.tar.bz2"
80
    URL_MD5 a70d79a6759367fbcc0bcc18d6866ff3
81
    PATCH_COMMAND patch -p0 < ${CMAKE_CURRENT_SOURCE_DIR}/JSCoverage.patch
82
    CONFIGURE_COMMAND "./configure"
83
    BUILD_IN_SOURCE 1
84
    INSTALL_COMMAND ""
85
)
86
set(JSCOVERAGE ${CMAKE_BINARY_DIR}/JSCoverage-prefix/src/JSCoverage/jscoverage)
87
88
# Android
89
if (NOT ANDROID_SDK_DIR)
90
  find_path(ANDROID_SDK_DIR platform-tools/aapt)
91
endif(NOT ANDROID_SDK_DIR)
92
if (NOT ANT)
93
  find_file(ANT NAMES ant ant.exe /usr/bin /usr/local/bin)
94
endif(NOT ANT)
95
96
add_subdirectory(webodf)
97
add_subdirectory(programs)
98
99
# package webodf
100
set(WEBODFZIP webodf-${WEBODF_VERSION}.zip)
101
set(WEBODFZIP_FILES
102
  ${CMAKE_BINARY_DIR}/webodf/webodf-debug.js
103
  ${CMAKE_BINARY_DIR}/webodf/webodf.js
104
  ${CMAKE_SOURCE_DIR}/webodf/webodf.css
105
)
106
add_custom_command(
107
    OUTPUT ${WEBODFZIP}
108
    # zip using javascript code running in node.js
109
    COMMAND ${NODE} ARGS webodf/lib/runtime.js packwebodf.js
110
        ${CMAKE_BINARY_DIR}/${WEBODFZIP}
111
#input files
112
        ${WEBODFZIP_FILES}
113
#output files
114
        webodf-debug.js
115
        webodf.js
116
        webodf.css
117
    DEPENDS NodeJS
118
        packwebodf.js
119
        ${WEBODFZIP_FILES}
120
        webodf-debug.js
121
        webodf.js
122
    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
123
)
124
add_custom_target(zip ALL DEPENDS ${WEBODFZIP})
125
126
# vim:expandtab