source: branches/work_304/CMakeLists.txt @ 327

Revision 327, 19.0 KB checked in by jls17, 6 years ago (diff)
Line 
1###############################################################################
2## Copyright (C) 2011 John Luthgers | jls17
3##
4## This file is part of ARInside.
5##
6##    ARInside is free software: you can redistribute it and/or modify
7##    it under the terms of the GNU General Public License as published by
8##    the Free Software Foundation, version 2 of the License.
9##
10##    ARInside is distributed in the hope that it will be useful,
11##    but WITHOUT ANY WARRANTY; without even the implied warranty of
12##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13##    GNU General Public License for more details.
14##
15##    You should have received a copy of the GNU General Public License
16##    along with ARInside.  If not, see <http://www.gnu.org/licenses/>.
17###############################################################################
18CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
19PROJECT(arinside)
20
21#SET(CMAKE_VERBOSE_MAKEFILE 1)       # OR USE AT CMD-LINE: -DCMAKE_VERBOSE_MAKEFILE=1       ## for verbose makefiles
22#SET(CMAKE_BUILD_TYPE Debug)         # OR USE AT CMD-LINE: -DCMAKE_BUILD_TYPE=Debug         ## for debug builds
23#SET(ARINSIDE_TARGET_ARCHITECTURE 4) # OR USE AT CMD-LINE: -DARINSIDE_TARGET_ARCHITECTURE=4 ## for 32bit build on 64bit platform
24
25MESSAGE(STATUS "System Name: ${CMAKE_SYSTEM_NAME}")
26
27## *** taken from http://stackoverflow.com/questions/148570/using-pre-compiled-headers-with-cmake ***
28## To use it, the PrecompiledSource file shouldn't be specified in SourceVar array. Otherwise the
29## file specific precompiled properties will get overwritten.
30MACRO(ADD_MSVC_PRECOMPILED_HEADER PrecompiledHeader PrecompiledSource SourcesVar)
31  IF(MSVC)
32        MESSAGE(STATUS "Setting up precompiler header support")
33    GET_FILENAME_COMPONENT(PrecompiledBasename ${PrecompiledHeader} NAME_WE)
34    SET(PrecompiledBinary "${CMAKE_CURRENT_BINARY_DIR}/${PrecompiledBasename}.pch")
35    SET(Sources ${${SourcesVar}})
36
37    SET_SOURCE_FILES_PROPERTIES(${PrecompiledSource}
38                                PROPERTIES COMPILE_FLAGS "/Yc\"${PrecompiledHeader}\" /Fp\"${PrecompiledBinary}\""
39                                           OBJECT_OUTPUTS "${PrecompiledBinary}")
40                                                                                   
41    SET_SOURCE_FILES_PROPERTIES(${Sources}
42                                PROPERTIES COMPILE_FLAGS "/Yu\"${PrecompiledBinary}\" /FI\"${PrecompiledBinary}\" /Fp\"${PrecompiledBinary}\""
43                                           OBJECT_DEPENDS "${PrecompiledBinary}") 
44    # Add precompiled header to SourcesVar
45    LIST(APPEND ${SourcesVar} ${PrecompiledSource})
46  ENDIF(MSVC)
47ENDMACRO(ADD_MSVC_PRECOMPILED_HEADER)
48
49# configurable variables for cmakegui
50IF(NOT DEFINED ARINSIDE_ENABLE_ZLIB_SUPPORT)
51        SET(ARINSIDE_ENABLE_ZLIB_SUPPORT CACHE BOOL "Enables zlib-compression support. See documentation for more details")
52ENDIF(NOT DEFINED ARINSIDE_ENABLE_ZLIB_SUPPORT)
53
54IF(NOT DEFINED ARINSIDE_BETA)
55        SET(ARINSIDE_BETA CACHE BOOL "When enabled, appends 'Beta' to the version string.")
56ENDIF(NOT DEFINED ARINSIDE_BETA)       
57
58IF (NOT DEFINED AR_INCLUDE_PATH)
59        SET(AR_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../api810" CACHE PATH "Path to the arapi root dir where 'include' and 'lib' is located.")
60ENDIF(NOT DEFINED AR_INCLUDE_PATH)
61
62IF(NOT EXISTS ${AR_INCLUDE_PATH})
63  MESSAGE(FATAL_ERROR "ARAPI include directory not found! Please set the AR_INCLUDE_PATH variable to the api root, where the directories 'include' and 'lib' are located. Current directory: ${AR_INCLUDE_PATH}
64use 'cmake -DAR_INCLUDE_PATH=/path/to/ars/api/dir'")
65ENDIF(NOT EXISTS ${AR_INCLUDE_PATH})
66
67if (NOT DEFINED ZLIB_INCLUDE_PATH)
68  SET(ZLIB_INCLUDE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../libs/zlib" CACHE PATH "Path to the zlib directory. Only used if ARINSIDE_ENABLE_ZLIB_SUPPORT ist enabled.")
69ENDIF(NOT DEFINED ZLIB_INCLUDE_PATH)
70
71IF(NOT DEFINED ARINSIDE_TARGET_ARCHITECTURE)
72        SET(ARINSIDE_TARGET_ARCHITECTURE ${CMAKE_SIZEOF_VOID_P})
73ENDIF(NOT DEFINED ARINSIDE_TARGET_ARCHITECTURE)
74
75INCLUDE_DIRECTORIES(${AR_INCLUDE_PATH}/include tinyxml/ tclap/ thirdparty/ ./ ${ZLIB_INCLUDE_PATH}/include)
76
77INCLUDE (CheckIncludeFiles)
78CHECK_INCLUDE_FILES("unistd.h" HAVE_UNISTD_H)
79CHECK_INCLUDE_FILES("strings.h" HAVE_STRINGS_H)
80
81CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
82CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/FileSystemUtilTest.h.in ${CMAKE_CURRENT_BINARY_DIR}/FileSystemUtilTest.h)
83
84ADD_DEFINITIONS(-DAR_STRICT_ANSI -D_CRT_SECURE_NO_DEPRECATE)
85IF(ARINSIDE_ENABLE_ZLIB_SUPPORT)
86        ADD_DEFINITIONS(-DARINSIDE_ENABLE_ZLIB_SUPPORT)
87ENDIF(ARINSIDE_ENABLE_ZLIB_SUPPORT)
88IF(ARINSIDE_BETA)
89        ADD_DEFINITIONS(-D_ARINSIDE_BETA)
90ENDIF(ARINSIDE_BETA)
91
92SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
93SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
94
95MESSAGE(STATUS "Is GNU CXX? -- ${CMAKE_COMPILER_IS_GNUCXX}")
96IF(UNIX AND CMAKE_COMPILER_IS_GNUCXX AND ARINSIDE_TARGET_ARCHITECTURE EQUAL 4 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
97        # use special compiler and linker flags on *nix platforms when doing 32bit cross-compile
98        ADD_DEFINITIONS(-m32)
99        SET(CMAKE_EXE_LINKER_FLAGS -m32)
100ENDIF(UNIX AND CMAKE_COMPILER_IS_GNUCXX AND ARINSIDE_TARGET_ARCHITECTURE EQUAL 4 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
101
102SET (ARINSIDE_SRCS
103 core/ARContainer.cpp core/ARGlobalField.cpp core/ARServerObject.cpp core/ARMessageObject.cpp
104 core/ARObject.cpp core/ARProplistHelper.cpp core/ARGroup.cpp core/ARAssignHelper.cpp
105 core/ARDayStructHelper.cpp core/ARFilter.cpp core/ARVui.cpp core/AREscalation.cpp core/ARQualification.cpp
106 core/ARServerInfo.cpp core/ARSchema.cpp core/ChangeHistoryEntry.cpp core/ARField.cpp core/ARUser.cpp
107 core/ARImage.cpp core/ARCharMenu.cpp core/ARRole.cpp core/ARActiveLink.cpp core/ARValue.cpp
108 core/ARSetFieldHelper.cpp core/ARHandle.cpp core/AREnum.cpp
109 doc/DocFieldDetails.cpp doc/DocFilterActionStruct.cpp doc/DocAlActionStruct.cpp doc/DocBase.cpp
110 doc/DocUserDetails.cpp doc/DocVuiDetails.cpp doc/DocWebserviceDetails.cpp doc/DocMain.cpp
111 doc/DocActionSetFieldsHelper.cpp doc/DocFilterGuideDetails.cpp doc/DocAlDetails.cpp
112 doc/DocCharMenuDetails.cpp doc/DocContainerHelper.cpp doc/DocRoleDetails.cpp doc/DocAnalyzer.cpp
113 doc/DocSchemaDetails.cpp doc/DocValidator.cpp doc/DocFilterDetails.cpp doc/DocImageDetails.cpp
114 doc/DocActionOpenWindowHelper.cpp doc/DocPacklistDetails.cpp doc/DocApplicationDetails.cpp
115 doc/DocGroupDetails.cpp doc/MessageItem.cpp doc/DocEscalationDetails.cpp doc/DocSummaryInfo.cpp
116 doc/DocAlGuideDetails.cpp doc/DocCustomWorkflow.cpp doc/DocOverlayHelper.cpp
117 lists/ARActiveLinkList.cpp lists/ARContainerList.cpp lists/AREscalationList.cpp lists/ARFieldList.cpp
118 lists/ARFilterList.cpp lists/ARGroupList.cpp lists/ARImageList.cpp lists/ARMenuList.cpp lists/ARRoleList.cpp
119 lists/ARSchemaList.cpp lists/ARUserList.cpp lists/ARVUIList.cpp lists/BlackList.cpp lists/ARListHelpers.cpp
120 lists/ARServerInfoList.cpp
121 output/Table.cpp output/TableCell.cpp output/WebControl.cpp output/AlTable.cpp output/EscalTable.cpp
122 output/UList.cpp output/FilterTable.cpp output/IFileStructure.cpp output/CsvPage.cpp output/ObjectTable.cpp
123 output/FileNaming.cpp output/TableRow.cpp output/SchemaTable.cpp output/RoleTable.cpp output/ContainerTable.cpp
124 output/WebPage.cpp output/TableColumn.cpp output/NavigationPage.cpp output/GroupTable.cpp output/ImageTable.cpp
125 output/UListItem.cpp output/MenuTable.cpp output/UserTable.cpp output/WebUtil.cpp output/TabControl.cpp
126 output/webpage/HtmlReferenceList.cpp output/webpage/HtmlReferenceListImpl.cpp
127 scan/ScanActiveLinks.cpp scan/ScanContainers.cpp scan/ScanEscalations.cpp scan/ScanFields.cpp scan/ScanFilters.cpp
128 scan/ScanImages.cpp scan/ScanMain.cpp scan/ScanMenus.cpp scan/ScanSchema.cpp
129 tinyxml/tinyxml.cpp tinyxml/tinystr.cpp tinyxml/tinyxmlerror.cpp tinyxml/tinyxmlparser.cpp
130 util/AppTimer.cpp util/BlackListItem.cpp util/CommandLineValidator.cpp util/RefItem.cpp
131 util/ResourceFileLocatorAndExtractor.h util/UntarStream.cpp util/Util.cpp
132 AppConfig.cpp AppConfigReader.cpp ARInside.cpp ConfigFile.cpp FileSystemUtil.cpp gzstream.cpp Main.cpp
133)
134SET (ARINSIDE_SRC_GIFS
135 res/active_link.gif res/al_guide.gif res/application.gif res/ars_edit.gif res/chapter.gif res/disabled.gif
136 res/doc.gif res/down.gif res/edit.gif res/empty_list.gif res/escalation.gif res/filter.gif res/filter_guide.gif
137 res/folder.gif res/group.gif res/hidden.gif res/image.gif res/info.gif res/menu.gif res/next.gif
138 res/packing_list.gif res/prev.gif res/schema.gif res/search.gif res/server.gif res/sort_asc.gif res/sort_desc.gif
139 res/up.gif res/user.gif res/visible.gif res/webservice.gif
140)
141SET (ARINSIDE_SRC_JS res/script.js res/sortscript.js res/tabscript.js res/schema_page.js res/arshelper.js)
142SET (ARINSIDE_SRC_CSS res/style.css)
143SET (ARINSIDE_JQUERY_RES
144        thirdparty/jquery/jquery-ui-custom.css
145        thirdparty/jquery/jquery-ui.js
146        thirdparty/jquery/jquery.address.min.js
147        thirdparty/jquery/jquery.js
148        thirdparty/jquery/jquery.timers.js
149        thirdparty/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png
150        thirdparty/jquery/images/ui-bg_glass_65_ffffff_1x400.png
151)
152SET (ARINSIDE_RESOURCES ${ARINSIDE_SRC_GIFS} ${ARINSIDE_SRC_JS} ${ARINSIDE_SRC_CSS} ${ARINSIDE_JQUERY_RES})
153
154SET(ARINSIDE_MAIN_SRCS ARInsideMain.cpp ARInsideMain.h)
155SET(ARINSIDE_TEST_SRCS ARInsideTest.cpp ARInsideTest.h
156 AppConfigReaderTest.cpp FileSystemUtilTest.cpp RapidJSONTests.cpp
157 lists/ARListHelpersTest.cpp
158 output/webpage/HtmlReferenceListImplTest.cpp
159 util/CommandLineValidatorTest.cpp util/UntarStreamTest.cpp util/UntarStreamTest.h
160)
161
162IF(NOT MSVC)
163        SET (ARINSIDE_SRCS ${ARINSIDE_SRCS} stdafx.cpp)
164ENDIF(NOT MSVC)
165
166# set link libraries for project
167IF(UNIX)
168        FIND_PACKAGE(Threads)
169        LINK_LIBRARIES(${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT})
170
171        ## solaris / aix specific libs
172        IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS" OR CMAKE_SYSTEM_NAME STREQUAL "AIX")
173                LINK_LIBRARIES(nsl)
174        ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS" OR CMAKE_SYSTEM_NAME STREQUAL "AIX")
175
176        IF(CMAKE_SYSTEM_NAME STREQUAL "AIX")
177                LINK_LIBRARIES(tli)
178        ENDIF(CMAKE_SYSTEM_NAME STREQUAL "AIX")
179       
180        IF(ARINSIDE_TARGET_ARCHITECTURE EQUAL 4 AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
181                ADD_DEFINITIONS(-malign-double)
182        ENDIF(ARINSIDE_TARGET_ARCHITECTURE EQUAL 4 AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
183ENDIF(UNIX)
184
185SET(ARINSIDE_ARAPI_ICUDATABMC_LIBNAME "icudatabmc")
186SET(ARINSIDE_ARAPI_ICUI18NBMC_LIBNAME "icui18nbmc")
187SET(ARINSIDE_ARAPI_ICUUCBMC_LIBNAME "icuucbmc")
188IF(WIN32)
189        SET(ARINSIDE_ARAPI_LIB arapi81_build001 arapi80_build001 arapi7604_build002 arapi7603_build001 arapi75 arapi71 arapi70)
190        SET(ZLIB_LIBNAMES zlibwapi)
191        SET(ARINSIDE_ADDITIONAL_LIBS shlwapi.lib)
192ELSE(WIN32)
193        SET(ARINSIDE_ARAPI_LIB ar)
194        SET(ZLIB_LIBNAMES z)
195ENDIF(WIN32)
196
197# set special library suffixes, compiler- and linker flags for 64-bit builds
198IF(ARINSIDE_TARGET_ARCHITECTURE EQUAL 8)
199        MESSAGE(STATUS "Building for 64 bit platform")
200        SET(TEMP_ARAPI_LIBS "")
201       
202        IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
203                SET(LIBAR_SUFFIX "_win64")
204        ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
205                SET(LIBAR_SUFFIX "_lx64")
206                IF(CMAKE_SIZEOF_VOID_P EQUAL 4) ## if we target 64-bit but the default is 32-bit, add some special flags
207                        ADD_DEFINITIONS(-m64)
208                        SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
209                ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4)
210        ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
211                SET(LIBAR_SUFFIX "_solsp64")
212                IF(CMAKE_SIZEOF_VOID_P EQUAL 4) ## if we target 64-bit but the default is 32-bit, add some special flags
213                        ADD_DEFINITIONS(-m64)
214                        SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
215                ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4)
216        ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "AIX")
217                SET(LIBAR_SUFFIX "_aixp64")
218                IF(CMAKE_SIZEOF_VOID_P EQUAL 4) ## if we target 64-bit but the default is 32-bit, add some special flags
219                        ADD_DEFINITIONS(-maix64 -mminimal-toc)
220                        SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-brtl -maix64")
221                ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4)
222        ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
223       
224        FOREACH(TEMP_ARAPI_LIB_NAME ${ARINSIDE_ARAPI_LIB})
225                LIST(APPEND TEMP_ARAPI_LIBS "${TEMP_ARAPI_LIB_NAME}${LIBAR_SUFFIX}")
226        ENDFOREACH()
227        SET(ARINSIDE_ARAPI_LIB ${TEMP_ARAPI_LIBS})
228       
229        SET(ARINSIDE_ARAPI_ICUDATABMC_LIBNAME "${ARINSIDE_ARAPI_ICUDATABMC_LIBNAME}${LIBAR_SUFFIX}")
230        SET(ARINSIDE_ARAPI_ICUI18NBMC_LIBNAME "${ARINSIDE_ARAPI_ICUI18NBMC_LIBNAME}${LIBAR_SUFFIX}")
231        SET(ARINSIDE_ARAPI_ICUUCBMC_LIBNAME "${ARINSIDE_ARAPI_ICUUCBMC_LIBNAME}${LIBAR_SUFFIX}")
232       
233        SET(ZLIB_LIB_PATH "${ZLIB_INCLUDE_PATH}/lib64")
234ELSE(ARINSIDE_TARGET_ARCHITECTURE EQUAL 8)
235        MESSAGE(STATUS "Building for 32 bit platform")
236        SET(ZLIB_LIB_PATH "${ZLIB_INCLUDE_PATH}/lib")
237ENDIF(ARINSIDE_TARGET_ARCHITECTURE EQUAL 8)
238
239FIND_LIBRARY(ARS_API_LIB NAMES ${ARINSIDE_ARAPI_LIB} PATHS ${AR_INCLUDE_PATH}/lib)
240FIND_LIBRARY(ARS_API_ICUDATABMC_LIB NAMES ${ARINSIDE_ARAPI_ICUDATABMC_LIBNAME} PATHS ${AR_INCLUDE_PATH}/lib)
241FIND_LIBRARY(ARS_API_ICUI18NBMC_LIB NAMES ${ARINSIDE_ARAPI_ICUI18NBMC_LIBNAME} PATHS ${AR_INCLUDE_PATH}/lib)
242FIND_LIBRARY(ARS_API_ICUUCBMC_LIB NAMES ${ARINSIDE_ARAPI_ICUUCBMC_LIBNAME} PATHS ${AR_INCLUDE_PATH}/lib)
243FIND_LIBRARY(ZLIB_LIB NAMES ${ZLIB_LIBNAMES} PATHS ${ZLIB_LIB_PATH})
244
245# check that necessary libs were found
246MESSAGE(STATUS "libar: (${ARINSIDE_ARAPI_LIB}) -- ${ARS_API_LIB}")
247IF (NOT ARS_API_LIB)
248        MESSAGE(FATAL_ERROR "Could not find ${ARINSIDE_ARAPI_LIB} in '${AR_INCLUDE_PATH}'! Please check or specify AR_INCLUDE_PATH variable")
249ENDIF (NOT ARS_API_LIB)
250
251IF (ARINSIDE_ENABLE_ZLIB_SUPPORT AND NOT ZLIB_LIB)
252        MESSAGE(FATAL_ERROR "Could not find ${ZLIB_LIBNAMES} in '${ZLIB_LIB_PATH}'! Please check or specify ZLIB_INCLUDE_PATH variable")
253ENDIF (ARINSIDE_ENABLE_ZLIB_SUPPORT AND NOT ZLIB_LIB)
254
255MESSAGE(STATUS "icudatabmc: (${ARINSIDE_ARAPI_ICUDATABMC_LIBNAME}) -- ${ARS_API_ICUDATABMC_LIB}")
256IF(ARS_API_ICUDATABMC_LIB)
257        LINK_LIBRARIES(${ARS_API_ICUDATABMC_LIB})
258ENDIF(ARS_API_ICUDATABMC_LIB)
259
260MESSAGE(STATUS "icui18nbmc: (${ARINSIDE_ARAPI_ICUI18NBMC_LIBNAME}) -- ${ARS_API_ICUI18NBMC_LIB}")
261IF(ARS_API_ICUI18NBMC_LIB)
262        LINK_LIBRARIES(${ARS_API_ICUI18NBMC_LIB})
263ENDIF(ARS_API_ICUI18NBMC_LIB)
264
265MESSAGE(STATUS "icuucbmc: (${ARINSIDE_ARAPI_ICUUCBMC_LIBNAME}) -- ${ARS_API_ICUUCBMC_LIB}")
266IF(ARS_API_ICUUCBMC_LIB)
267        LINK_LIBRARIES(${ARS_API_ICUUCBMC_LIB})
268ENDIF(ARS_API_ICUUCBMC_LIB)
269
270# now generate and import resources
271IF(UNIX)
272        IF(NOT DEFINED ARINSIDE_RESOURCES_ALREADY_BUILD)
273                INCLUDE_DIRECTORIES(${arinside_BINARY_DIR}/res)
274                FILE(MAKE_DIRECTORY ${arinside_BINARY_DIR}/res)
275                SET(ARINSIDE_GENERATED_RESOURCE_SRC_FILES "")
276                FOREACH(res ${ARINSIDE_RESOURCES})
277                        MESSAGE(STATUS "Generating ${res}.cpp ...")
278                        FILE(READ ${res} ARINSIDE_RES_OBJECT HEX)
279                        STRING(LENGTH ${ARINSIDE_RES_OBJECT} ARINSIDE_RES_OBJECT_LENGTH)
280                        SET(ARINSIDE_RES_OBJECT_CONTENT "")
281                        SET(ARINSIDE_RES_OBJECT_POSITION 0)
282                        WHILE(${ARINSIDE_RES_OBJECT_POSITION} LESS ${ARINSIDE_RES_OBJECT_LENGTH})
283                                STRING(SUBSTRING ${ARINSIDE_RES_OBJECT} ${ARINSIDE_RES_OBJECT_POSITION} 2 RES_CHAR)
284                                MATH(EXPR ARINSIDE_RES_OBJECT_POSITION "${ARINSIDE_RES_OBJECT_POSITION}+2")
285
286                                IF(NOT ${ARINSIDE_RES_OBJECT_CONTENT} STREQUAL "")
287                                        SET(ARINSIDE_RES_OBJECT_CONTENT "${ARINSIDE_RES_OBJECT_CONTENT},")
288                                ENDIF(NOT ${ARINSIDE_RES_OBJECT_CONTENT} STREQUAL "")
289
290                                SET(ARINSIDE_RES_OBJECT_CONTENT "${ARINSIDE_RES_OBJECT_CONTENT}0x${RES_CHAR}")
291                        ENDWHILE(${ARINSIDE_RES_OBJECT_POSITION} LESS ${ARINSIDE_RES_OBJECT_LENGTH})
292                       
293                        STRING(REGEX REPLACE "[^A-Za-z0-9]" "_" RES_OBJECT_NAME "${res}")
294                        SET(RES_OBJECT_NAME "_binary_${RES_OBJECT_NAME}")
295                        MATH(EXPR ARINSIDE_RES_REAL_OBJECT_LENGTH "${ARINSIDE_RES_OBJECT_LENGTH}/2")
296                        SET(ARINSIDE_RES_OBJECT_CONTENT "unsigned char ${RES_OBJECT_NAME}_start[] = {${ARINSIDE_RES_OBJECT_CONTENT}};\nunsigned int ${RES_OBJECT_NAME}_size = ${ARINSIDE_RES_REAL_OBJECT_LENGTH};\n\n")
297                       
298                        SET(RES_OUTPUT_NAME "${arinside_BINARY_DIR}/${res}.cpp")
299                        FILE(WRITE ${RES_OUTPUT_NAME} "${ARINSIDE_RES_OBJECT_CONTENT}")
300                       
301                        LIST(APPEND ARINSIDE_GENERATED_RESOURCE_SRC_FILES ${res}.cpp)
302                ENDFOREACH(res)
303                SET(ARINSIDE_RESOURCES_ALREADY_BUILD 1 CACHE INTERNAL "to remember resources are already build")
304                SET(ARINSIDE_GENERATED_RESOURCE_SRC_FILES ${ARINSIDE_GENERATED_RESOURCE_SRC_FILES} CACHE INTERNAL "to remember build source files")
305        ENDIF(NOT DEFINED ARINSIDE_RESOURCES_ALREADY_BUILD)
306        SET(ARINSIDE_SRCS ${ARINSIDE_SRCS} ${ARINSIDE_GENERATED_RESOURCE_SRC_FILES})
307ELSE(UNIX)
308        SET(ARINSIDE_SRCS ${ARINSIDE_SRCS} "ARInside.rc")
309        SET(ARINSIDE_MAIN_SRCS ${ARINSIDE_MAIN_SRCS} "ARInside.rc")
310ENDIF(UNIX)
311
312ADD_MSVC_PRECOMPILED_HEADER("stdafx.h" "stdafx.cpp" ARINSIDE_SRCS)
313
314# generate svnrev.h file
315FIND_PACKAGE(Subversion)
316IF(Subversion_FOUND)
317        Subversion_WC_INFO(${PROJECT_SOURCE_DIR} ARINSIDE)
318ELSE(Subversion_FOUND)
319        SET(ARINSIDE_WC_REVISION SVNMISS)
320ENDIF(Subversion_FOUND)
321FILE(READ ${PROJECT_SOURCE_DIR}/svnrev_template.h SVNREV_TEMPLATE)
322STRING(REPLACE "$WCREV$" ${ARINSIDE_WC_REVISION} SVNREV_TEMPLATE "${SVNREV_TEMPLATE}")
323FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/svnrev.h ${SVNREV_TEMPLATE})
324INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
325
326# now setup testing ... http://stackoverflow.com/questions/9689183/cmake-googletest
327INCLUDE(ExternalProject)
328SET_DIRECTORY_PROPERTIES(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/thirdparty)
329ExternalProject_Add(
330        googletest
331        URL http://googletest.googlecode.com/files/gtest-1.6.0.zip
332        TIMEOUT 10
333        # Force separate output paths for debug and release builds to allow easy
334        # identification of correct lib in subsequent TARGET_LINK_LIBRARIES commands
335        CMAKE_ARGS -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=DebugLibs
336                           -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=ReleaseLibs
337                           -Dgtest_force_shared_crt=ON
338        # Disable install step
339        INSTALL_COMMAND ""
340        # Wrap download, configure and build steps in a script to log output
341        ###These LOG_XXX params are only supported in cmake2.8.3+ and are disabled here to get backwards compatibility with 2.8.0
342        #LOG_DOWNLOAD ON
343        #LOG_CONFIGURE ON
344        #LOG_BUILD ON
345)
346       
347ExternalProject_Get_Property(googletest source_dir)
348INCLUDE_DIRECTORIES(${source_dir}/include)
349ExternalProject_Get_Property(googletest binary_dir)
350SET(GTEST_BINARY_DIR ${binary_dir})
351ENABLE_TESTING()
352
353LINK_DIRECTORIES(${GTEST_BINARY_DIR})
354
355# setup output target
356ADD_LIBRARY(arinsidelib ${ARINSIDE_SRCS} ${ARINSIDE_RESOURCE_OBJECTS})
357ADD_EXECUTABLE(arinside ${ARINSIDE_MAIN_SRCS})
358ADD_EXECUTABLE(arinsidetest ${ARINSIDE_TEST_SRCS})
359
360# dependencies
361ADD_DEPENDENCIES(arinsidetest arinsidelib googletest)
362ADD_DEPENDENCIES(arinside arinsidelib)
363
364# reference the needed libraries
365TARGET_LINK_LIBRARIES(arinside ${ARS_API_LIB} ${ZLIB_LIB} ${ARINSIDE_ADDITIONAL_LIBS} arinsidelib)
366TARGET_LINK_LIBRARIES(arinsidetest ${ARS_API_LIB} ${ZLIB_LIB} ${ARINSIDE_ADDITIONAL_LIBS} arinsidelib)
367IF(MSVC)
368        TARGET_LINK_LIBRARIES(arinsidetest
369                debug ${GTEST_BINARY_DIR}/DebugLibs/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_FIND_LIBRARY_SUFFIXES}
370                optimized ${GTEST_BINARY_DIR}/ReleaseLibs/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_FIND_LIBRARY_SUFFIXES}
371        )
372ELSE(MSVC)
373        TARGET_LINK_LIBRARIES(arinsidetest gtest)
374ENDIF(MSVC)
375
376ADD_TEST(NAME test COMMAND arinsidetest)
377#INSTALL(TARGETS arinside DESTINATION bin)
Note: See TracBrowser for help on using the repository browser.