|
1 # Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
2 # |
|
3 # Permission is hereby granted, free of charge, to any person obtaining a |
|
4 # copy of this software and /or associated documentation files |
|
5 # (the "Materials "), to deal in the Materials without restriction, |
|
6 # including without limitation the rights to use, copy, modify, merge, |
|
7 # publish, distribute, sublicense, and/or sell copies of the Materials, |
|
8 # and to permit persons to whom the Materials are furnished to do so, |
|
9 # subject to the following conditions: |
|
10 # |
|
11 # The above copyright notice and this permission notice shall be included |
|
12 # in all copies or substantial portions of the Materials. |
|
13 # |
|
14 # THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
15 # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
16 # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. |
|
17 # IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, |
|
18 # DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR |
|
19 # OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE MATERIALS OR |
|
20 # THE USE OR OTHER DEALINGS IN THE MATERIALS. |
|
21 # |
|
22 # Initial Contributors: |
|
23 # Nokia Corporation - initial contribution. |
|
24 # |
|
25 # Contributors: |
|
26 # |
|
27 # Description: |
|
28 # CMake meta build file for host libOpenVG |
|
29 |
|
30 set(SF_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src) |
|
31 |
|
32 # Some of the source files are generated using scripts. Check if the |
|
33 # scripts were modified and rebuild if necessary. |
|
34 set(ALPHA_RCP_GEN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/genheader/make_alpha_rcp.py) |
|
35 set(GAMMA_LUT_GEN_FILE ${CMAKE_CURRENT_SOURCE_DIR}/genheader/make_gamma_lut.py) |
|
36 |
|
37 set(ALPHA_RCP_FILE ${SF_SRC_DIR}/sfAlphaRcp.h) |
|
38 set(GAMMA_LUT_FILE ${SF_SRC_DIR}/sfGammaLUT.h) |
|
39 |
|
40 add_custom_command( |
|
41 OUTPUT ${ALPHA_RCP_FILE} |
|
42 COMMAND python ${ALPHA_RCP_GEN_FILE} > ${ALPHA_RCP_FILE} |
|
43 DEPENDS ${ALPHA_RCP_GEN_FILE}) |
|
44 |
|
45 add_custom_command( |
|
46 OUTPUT ${GAMMA_LUT_FILE} |
|
47 COMMAND python ${GAMMA_LUT_GEN_FILE} > ${GAMMA_LUT_FILE} |
|
48 DEPENDS ${GAMMA_LUT_GEN_FILE}) |
|
49 |
|
50 # Required in Linux and for LLVM compilation: |
|
51 # \todo LLVM script uses the flags differently, so they must be manually changed! |
|
52 set(GCC_SSE_FLAGS "-msse2 -mfpmath=sse -march=pentium4") |
|
53 |
|
54 # Win32 vs. Linux settings |
|
55 if(WIN32) |
|
56 message("*** openvg_sg Win32") |
|
57 set(SF_SSE_FLAGS "/arch:SSE2") |
|
58 set(SF_PLATFORM_LINK_LIBRARIES "") |
|
59 set(C_WARNING_FLAGS "") |
|
60 add_definitions(-DOPENVG_DLL_EXPORTS -DNOMINMAX) |
|
61 |
|
62 set(GLUT_LIBRARY "") |
|
63 set(GLUT_INCLUDE_DIR "") |
|
64 |
|
65 set(LIB_TYPE SHARED) |
|
66 |
|
67 else(WIN32) |
|
68 set(SF_SSE_FLAGS ${GCC_SSE_FLAGS}) |
|
69 set(SF_PLATFORM_LINK_LIBRARIES m stdc++) |
|
70 set(C_WARNING_FLAGS "-Wall -std=c99 -pedantic-errors -Wno-variadic-macros -Wno-long-long -Wextra") |
|
71 set(CXX_WARNING_FLAGS "-Wall -std=c++98 -pedantic-errors -Wno-variadic-macros -Wno-long-long -Wextra") |
|
72 |
|
73 # Easier debugging on linux |
|
74 # \todo Just use BUILD_SHARED_LIBRARIES: This way debug builds can be made with static |
|
75 # and release with dynamic linking. |
|
76 set(LIB_TYPE SHARED) |
|
77 |
|
78 find_library(GLUT_LIBRARY glut) |
|
79 find_path(GLUT_INCLUDE_DIR GL/glut.h) |
|
80 endif(WIN32) |
|
81 |
|
82 |
|
83 set(VG_SF_SRC_FILES |
|
84 ${SF_SRC_DIR}/sfEGLInterface.h |
|
85 ${SF_SRC_DIR}/sfEGLInterface.cpp |
|
86 ${SF_SRC_DIR}/riApi.cpp |
|
87 ${SF_SRC_DIR}/riArray.h |
|
88 ${SF_SRC_DIR}/riContext.cpp |
|
89 ${SF_SRC_DIR}/riContext.h |
|
90 ${SF_SRC_DIR}/riDefs.h |
|
91 ${SF_SRC_DIR}/riFont.cpp |
|
92 ${SF_SRC_DIR}/riUtils.h |
|
93 ${SF_SRC_DIR}/riUtils.cpp |
|
94 ${SF_SRC_DIR}/riFont.h |
|
95 ${SF_SRC_DIR}/riImage.cpp |
|
96 ${SF_SRC_DIR}/riImage.h |
|
97 ${SF_SRC_DIR}/riMath.cpp |
|
98 ${SF_SRC_DIR}/riMath.h |
|
99 ${SF_SRC_DIR}/riPath.cpp |
|
100 ${SF_SRC_DIR}/riPath.h |
|
101 ${SF_SRC_DIR}/riPixelPipe.cpp |
|
102 ${SF_SRC_DIR}/riPixelPipe.h |
|
103 ${SF_SRC_DIR}/riRasterizer.cpp |
|
104 ${SF_SRC_DIR}/riRasterizer.h |
|
105 ${SF_SRC_DIR}/riVGU.cpp |
|
106 ${SF_SRC_DIR}/sfMask.h |
|
107 ${SF_SRC_DIR}/sfDynamicPixelPipe.h |
|
108 ${SF_SRC_DIR}/sfDynamicPixelPipe.cpp |
|
109 ${SF_SRC_DIR}/sfBlitter.h |
|
110 ${SF_SRC_DIR}/sfBlitter.cpp |
|
111 ${SF_SRC_DIR}/sfDynamicBlitter.h |
|
112 ${SF_SRC_DIR}/sfDynamicBlitter.cpp |
|
113 ${SF_SRC_DIR}/sfFunctionCache.h |
|
114 ${SF_SRC_DIR}/sfCompiler.h |
|
115 ${SF_SRC_DIR}/sfCompiler.cpp |
|
116 ${ALPHA_RCP_FILE} |
|
117 ${GAMMA_LUT_FILE} |
|
118 ) |
|
119 |
|
120 # This VG requires OpenGL to render into window |
|
121 find_package(OpenGL) |
|
122 |
|
123 # pthreads on linux, native threads on win32? |
|
124 # \note Porting... |
|
125 find_package(Threads) |
|
126 |
|
127 include_directories( |
|
128 ${SF_SRC_DIR} |
|
129 ${COMMON_INC_DIR} |
|
130 ${COMMON_INC_DIR}/VG |
|
131 ${LLVM_INCLUDE_DIR} |
|
132 ${CMAKE_CURRENT_BINARY_DIR} |
|
133 ) |
|
134 |
|
135 # -fvisibility=hidden? |
|
136 set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${SF_SSE_FLAGS} ${C_WARNING_FLAGS}") |
|
137 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SF_SSE_FLAGS} ${CXX_WARNING_FLAGS}") |
|
138 # These preprocessor flags were defined in the visual studio project file: |
|
139 # RI_COMPILE_LLVM_BYTECODE;WIN32;NDEBUG;_WINDOWS;_USRDLL;LIBOPENVG_EXPORTS;OPENVG_DLL_EXPORTS;__STDC_LIMIT_MACROS;__STDC_CONSTANT_MACROS;_CRT_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;CRT_NONSTDC_NO_WARNINGS;_SCL_SECURE_NO_DEPRECATE |
|
140 |
|
141 # \note This compiles the full version (nothing is generated) |
|
142 add_definitions(-D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -DRI_COMPILE_LLVM_BYTECODE) |
|
143 |
|
144 # LLVM bitcode files. \todo Create a macro to add these (LLVMTarget has some |
|
145 # code that needs expansion, especially on the dependencies, which aren't |
|
146 # handled well enough for our use. |
|
147 set(BC_CFLAGS ${BC_CFLAGS} -DNDEBUG -O1 -msse2 -mfpmath=sse -march=pentium4 -c -emit-llvm -I${COMMON_INC_DIR} ) |
|
148 |
|
149 # This macro assumes that a pixelpipe is generated from one source-code file atm. |
|
150 macro(make_pixelpipe target_name input_file output_file array_name) |
|
151 set(BINARY_PIXELPIPE_DIR ${CMAKE_CURRENT_BINARY_DIR}) |
|
152 set(BINARY_PIXELPIPE_TARGET ${target_name}) |
|
153 set(BINARY_PIXELPIPE_FILE ${CMAKE_CURRENT_BINARY_DIR}/${BINARY_PIXELPIPE_TARGET}.bc) |
|
154 set(BINARY_PIXELPIPE_HEADER ${BINARY_PIXELPIPE_DIR}/${output_file}) |
|
155 |
|
156 set_source_files_properties(${BINARY_PIXELPIPE_HEADER} |
|
157 PROPERTIES GENERATED true) |
|
158 |
|
159 set(LLVM_PIXELPIPE_FILES ${SF_SRC_DIR}/${input_file}) |
|
160 |
|
161 # Note: Adds all project files as dependency to bitcode file. |
|
162 add_custom_command( |
|
163 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${input_file}.bc |
|
164 COMMAND ${LLVM_CC} ARGS ${BC_CFLAGS} -o ${CMAKE_CURRENT_BINARY_DIR}/${input_file}.bc ${LLVM_PIXELPIPE_FILES} |
|
165 DEPENDS ${LLVM_PIXELPIPE_FILES} ${VG_SF_SRC_FILES} |
|
166 ) |
|
167 |
|
168 add_custom_command( |
|
169 OUTPUT ${BINARY_PIXELPIPE_FILE} |
|
170 COMMAND ${LLVM_LINK} ARGS -f -o ${BINARY_PIXELPIPE_FILE} ${CMAKE_CURRENT_BINARY_DIR}/${input_file}.bc |
|
171 DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${input_file}.bc |
|
172 ) |
|
173 |
|
174 set(BINARY_PIXELPIPE_HEADER_DEPS ${BINARY_PIXELPIPE_FILE}) |
|
175 |
|
176 if(CMAKE_BUILD_TYPE STREQUAL Debug) |
|
177 add_custom_command( |
|
178 OUTPUT ${BINARY_PIXELPIPE_FILE}.disasm |
|
179 COMMAND ${LLVM_DIS} ARGS ${BINARY_PIXELPIPE_FILE} -f -o ${BINARY_PIXELPIPE_FILE}.disasm |
|
180 DEPENDS ${BINARY_PIXELPIPE_FILE} |
|
181 ) |
|
182 set(BINARY_PIXELPIPE_HEADER_DEPS ${BINARY_PIXELPIPE_DEPS} ${BINARY_PIXELPIPE_FILE}.disasm) |
|
183 endif() |
|
184 |
|
185 add_custom_command( |
|
186 OUTPUT ${BINARY_PIXELPIPE_HEADER} |
|
187 COMMAND python ${PROJECT_SOURCE_DIR}/vg/bin/bin2h.py ${BINARY_PIXELPIPE_FILE} ${array_name} > ${BINARY_PIXELPIPE_HEADER} |
|
188 DEPENDS ${BINARY_PIXELPIPE_HEADER_DEPS} |
|
189 ) |
|
190 |
|
191 set(VG_SF_SRC_FILES ${VG_SF_SRC_FILES} ${BINARY_PIXELPIPE_HEADER}) |
|
192 endmacro(make_pixelpipe) |
|
193 |
|
194 make_pixelpipe(llvm_pixelpipe sfDynamicPixelPipe.cpp binaryPixelPipe.h integerPixelPipe_binary) |
|
195 make_pixelpipe(llvm_blitter sfDynamicBlitter.cpp binaryBlitter.h integerBlitter_binary) |
|
196 |
|
197 add_library(${LIBRARY_NAME_PREFIX}OpenVG ${LIB_TYPE} ${VG_SF_SRC_FILES}) |
|
198 |
|
199 set_target_properties(${LIBRARY_NAME_PREFIX}OpenVG PROPERTIES LINK_INTERFACE_LIBRARIES "") |
|
200 |
|
201 target_link_libraries(${LIBRARY_NAME_PREFIX}OpenVG ${SF_PLATFORM_LINK_LIBRARIES} ${OPENGL_LIBRARIES} ${GLUT_LIBRARY} ${CMAKE_THREAD_LIBS_INIT} ${LLVM_JIT_LIBS}) |