source: branches/work_304/CMakeLists.txt @ 326

Revision 326, 18.8 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)
82
83ADD_DEFINITIONS(-DAR_STRICT_ANSI -D_CRT_SECURE_NO_DEPRECATE)
84IF(ARINSIDE_ENABLE_ZLIB_SUPPORT)
85        ADD_DEFINITIONS(-DARINSIDE_ENABLE_ZLIB_SUPPORT)
86ENDIF(ARINSIDE_ENABLE_ZLIB_SUPPORT)
87IF(ARINSIDE_BETA)
88        ADD_DEFINITIONS(-D_ARINSIDE_BETA)
89ENDIF(ARINSIDE_BETA)
90
91SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
92SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
93
94MESSAGE(STATUS "Is GNU CXX? -- ${CMAKE_COMPILER_IS_GNUCXX}")
95IF(UNIX AND CMAKE_COMPILER_IS_GNUCXX AND ARINSIDE_TARGET_ARCHITECTURE EQUAL 4 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
96        # use special compiler and linker flags on *nix platforms when doing 32bit cross-compile
97        ADD_DEFINITIONS(-m32)
98        SET(CMAKE_EXE_LINKER_FLAGS -m32)
99ENDIF(UNIX AND CMAKE_COMPILER_IS_GNUCXX AND ARINSIDE_TARGET_ARCHITECTURE EQUAL 4 AND CMAKE_SIZEOF_VOID_P EQUAL 8)
100
101SET (ARINSIDE_SRCS
102 core/ARContainer.cpp core/ARGlobalField.cpp core/ARServerObject.cpp core/ARMessageObject.cpp
103 core/ARObject.cpp core/ARProplistHelper.cpp core/ARGroup.cpp core/ARAssignHelper.cpp
104 core/ARDayStructHelper.cpp core/ARFilter.cpp core/ARVui.cpp core/AREscalation.cpp core/ARQualification.cpp
105 core/ARServerInfo.cpp core/ARSchema.cpp core/ChangeHistoryEntry.cpp core/ARField.cpp core/ARUser.cpp
106 core/ARImage.cpp core/ARCharMenu.cpp core/ARRole.cpp core/ARActiveLink.cpp core/ARValue.cpp
107 core/ARSetFieldHelper.cpp core/ARHandle.cpp core/AREnum.cpp
108 doc/DocFieldDetails.cpp doc/DocFilterActionStruct.cpp doc/DocAlActionStruct.cpp doc/DocBase.cpp
109 doc/DocUserDetails.cpp doc/DocVuiDetails.cpp doc/DocWebserviceDetails.cpp doc/DocMain.cpp
110 doc/DocActionSetFieldsHelper.cpp doc/DocFilterGuideDetails.cpp doc/DocAlDetails.cpp
111 doc/DocCharMenuDetails.cpp doc/DocContainerHelper.cpp doc/DocRoleDetails.cpp doc/DocAnalyzer.cpp
112 doc/DocSchemaDetails.cpp doc/DocValidator.cpp doc/DocFilterDetails.cpp doc/DocImageDetails.cpp
113 doc/DocActionOpenWindowHelper.cpp doc/DocPacklistDetails.cpp doc/DocApplicationDetails.cpp
114 doc/DocGroupDetails.cpp doc/MessageItem.cpp doc/DocEscalationDetails.cpp doc/DocSummaryInfo.cpp
115 doc/DocAlGuideDetails.cpp doc/DocCustomWorkflow.cpp doc/DocOverlayHelper.cpp
116 lists/ARActiveLinkList.cpp lists/ARContainerList.cpp lists/AREscalationList.cpp lists/ARFieldList.cpp
117 lists/ARFilterList.cpp lists/ARGroupList.cpp lists/ARImageList.cpp lists/ARMenuList.cpp lists/ARRoleList.cpp
118 lists/ARSchemaList.cpp lists/ARUserList.cpp lists/ARVUIList.cpp lists/BlackList.cpp lists/ARListHelpers.cpp
119 lists/ARServerInfoList.cpp
120 output/Table.cpp output/TableCell.cpp output/WebControl.cpp output/AlTable.cpp output/EscalTable.cpp
121 output/UList.cpp output/FilterTable.cpp output/IFileStructure.cpp output/CsvPage.cpp output/ObjectTable.cpp
122 output/FileNaming.cpp output/TableRow.cpp output/SchemaTable.cpp output/RoleTable.cpp output/ContainerTable.cpp
123 output/WebPage.cpp output/TableColumn.cpp output/NavigationPage.cpp output/GroupTable.cpp output/ImageTable.cpp
124 output/UListItem.cpp output/MenuTable.cpp output/UserTable.cpp output/WebUtil.cpp output/TabControl.cpp
125 output/webpage/HtmlReferenceList.cpp output/webpage/HtmlReferenceListImpl.cpp
126 scan/ScanActiveLinks.cpp scan/ScanContainers.cpp scan/ScanEscalations.cpp scan/ScanFields.cpp scan/ScanFilters.cpp
127 scan/ScanImages.cpp scan/ScanMain.cpp scan/ScanMenus.cpp scan/ScanSchema.cpp
128 tinyxml/tinyxml.cpp tinyxml/tinystr.cpp tinyxml/tinyxmlerror.cpp tinyxml/tinyxmlparser.cpp
129 util/AppTimer.cpp util/BlackListItem.cpp util/CommandLineValidator.cpp util/RefItem.cpp
130 util/ResourceFileLocatorAndExtractor.h util/UntarStream.cpp util/Util.cpp
131 AppConfig.cpp AppConfigReader.cpp ARInside.cpp ConfigFile.cpp FileSystemUtil.cpp gzstream.cpp Main.cpp
132)
133SET (ARINSIDE_SRC_GIFS
134 res/active_link.gif res/al_guide.gif res/application.gif res/ars_edit.gif res/chapter.gif res/disabled.gif
135 res/doc.gif res/down.gif res/edit.gif res/empty_list.gif res/escalation.gif res/filter.gif res/filter_guide.gif
136 res/folder.gif res/group.gif res/hidden.gif res/image.gif res/info.gif res/menu.gif res/next.gif
137 res/packing_list.gif res/prev.gif res/schema.gif res/search.gif res/server.gif res/sort_asc.gif res/sort_desc.gif
138 res/up.gif res/user.gif res/visible.gif res/webservice.gif
139)
140SET (ARINSIDE_SRC_JS res/script.js res/sortscript.js res/tabscript.js res/schema_page.js res/arshelper.js)
141SET (ARINSIDE_SRC_CSS res/style.css)
142SET (ARINSIDE_JQUERY_RES
143        thirdparty/jquery/jquery-ui-custom.css
144        thirdparty/jquery/jquery-ui.js
145        thirdparty/jquery/jquery.address.min.js
146        thirdparty/jquery/jquery.js
147        thirdparty/jquery/jquery.timers.js
148        thirdparty/jquery/images/ui-bg_glass_75_e6e6e6_1x400.png
149        thirdparty/jquery/images/ui-bg_glass_65_ffffff_1x400.png
150)
151SET (ARINSIDE_RESOURCES ${ARINSIDE_SRC_GIFS} ${ARINSIDE_SRC_JS} ${ARINSIDE_SRC_CSS} ${ARINSIDE_JQUERY_RES})
152
153SET(ARINSIDE_MAIN_SRCS ARInsideMain.cpp ARInsideMain.h)
154SET(ARINSIDE_TEST_SRCS ARInsideTest.cpp ARInsideTest.h
155 AppConfigReaderTest.cpp FileSystemUtilTest.cpp RapidJSONTests.cpp
156 lists/ARListHelpersTest.cpp
157 output/webpage/HtmlReferenceListImplTest.cpp
158 util/CommandLineValidatorTest.cpp util/UntarStreamTest.cpp util/UntarStreamTest.h
159)
160
161IF(NOT MSVC)
162        SET (ARINSIDE_SRCS ${ARINSIDE_SRCS} stdafx.cpp)
163ENDIF(NOT MSVC)
164
165# set link libraries for project
166IF(UNIX)
167        FIND_PACKAGE(Threads)
168        LINK_LIBRARIES(${CMAKE_DL_LIBS} ${CMAKE_THREAD_LIBS_INIT})
169
170        ## solaris / aix specific libs
171        IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS" OR CMAKE_SYSTEM_NAME STREQUAL "AIX")
172                LINK_LIBRARIES(nsl)
173        ENDIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS" OR CMAKE_SYSTEM_NAME STREQUAL "AIX")
174
175        IF(CMAKE_SYSTEM_NAME STREQUAL "AIX")
176                LINK_LIBRARIES(tli)
177        ENDIF(CMAKE_SYSTEM_NAME STREQUAL "AIX")
178       
179        IF(ARINSIDE_TARGET_ARCHITECTURE EQUAL 4 AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
180                ADD_DEFINITIONS(-malign-double)
181        ENDIF(ARINSIDE_TARGET_ARCHITECTURE EQUAL 4 AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
182ENDIF(UNIX)
183
184SET(ARINSIDE_ARAPI_ICUDATABMC_LIBNAME "icudatabmc")
185SET(ARINSIDE_ARAPI_ICUI18NBMC_LIBNAME "icui18nbmc")
186SET(ARINSIDE_ARAPI_ICUUCBMC_LIBNAME "icuucbmc")
187IF(WIN32)
188        SET(ARINSIDE_ARAPI_LIB arapi81_build001 arapi80_build001 arapi7604_build002 arapi7603_build001 arapi75 arapi71 arapi70)
189        SET(ZLIB_LIBNAMES zlibwapi)
190ELSE(WIN32)
191        SET(ARINSIDE_ARAPI_LIB ar)
192        SET(ZLIB_LIBNAMES z)
193ENDIF(WIN32)
194
195# set special library suffixes, compiler- and linker flags for 64-bit builds
196IF(ARINSIDE_TARGET_ARCHITECTURE EQUAL 8)
197        MESSAGE(STATUS "Building for 64 bit platform")
198        SET(TEMP_ARAPI_LIBS "")
199       
200        IF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
201                SET(LIBAR_SUFFIX "_win64")
202        ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
203                SET(LIBAR_SUFFIX "_lx64")
204                IF(CMAKE_SIZEOF_VOID_P EQUAL 4) ## if we target 64-bit but the default is 32-bit, add some special flags
205                        ADD_DEFINITIONS(-m64)
206                        SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
207                ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4)
208        ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
209                SET(LIBAR_SUFFIX "_solsp64")
210                IF(CMAKE_SIZEOF_VOID_P EQUAL 4) ## if we target 64-bit but the default is 32-bit, add some special flags
211                        ADD_DEFINITIONS(-m64)
212                        SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -m64")
213                ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4)
214        ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "AIX")
215                SET(LIBAR_SUFFIX "_aixp64")
216                IF(CMAKE_SIZEOF_VOID_P EQUAL 4) ## if we target 64-bit but the default is 32-bit, add some special flags
217                        ADD_DEFINITIONS(-maix64 -mminimal-toc)
218                        SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-brtl -maix64")
219                ENDIF(CMAKE_SIZEOF_VOID_P EQUAL 4)
220        ENDIF(CMAKE_SYSTEM_NAME STREQUAL "Windows")
221       
222        FOREACH(TEMP_ARAPI_LIB_NAME ${ARINSIDE_ARAPI_LIB})
223                LIST(APPEND TEMP_ARAPI_LIBS "${TEMP_ARAPI_LIB_NAME}${LIBAR_SUFFIX}")
224        ENDFOREACH()
225        SET(ARINSIDE_ARAPI_LIB ${TEMP_ARAPI_LIBS})
226       
227        SET(ARINSIDE_ARAPI_ICUDATABMC_LIBNAME "${ARINSIDE_ARAPI_ICUDATABMC_LIBNAME}${LIBAR_SUFFIX}")
228        SET(ARINSIDE_ARAPI_ICUI18NBMC_LIBNAME "${ARINSIDE_ARAPI_ICUI18NBMC_LIBNAME}${LIBAR_SUFFIX}")
229        SET(ARINSIDE_ARAPI_ICUUCBMC_LIBNAME "${ARINSIDE_ARAPI_ICUUCBMC_LIBNAME}${LIBAR_SUFFIX}")
230       
231        SET(ZLIB_LIB_PATH "${ZLIB_INCLUDE_PATH}/lib64")
232ELSE(ARINSIDE_TARGET_ARCHITECTURE EQUAL 8)
233        MESSAGE(STATUS "Building for 32 bit platform")
234        SET(ZLIB_LIB_PATH "${ZLIB_INCLUDE_PATH}/lib")
235ENDIF(ARINSIDE_TARGET_ARCHITECTURE EQUAL 8)
236
237FIND_LIBRARY(ARS_API_LIB NAMES ${ARINSIDE_ARAPI_LIB} PATHS ${AR_INCLUDE_PATH}/lib)
238FIND_LIBRARY(ARS_API_ICUDATABMC_LIB NAMES ${ARINSIDE_ARAPI_ICUDATABMC_LIBNAME} PATHS ${AR_INCLUDE_PATH}/lib)
239FIND_LIBRARY(ARS_API_ICUI18NBMC_LIB NAMES ${ARINSIDE_ARAPI_ICUI18NBMC_LIBNAME} PATHS ${AR_INCLUDE_PATH}/lib)
240FIND_LIBRARY(ARS_API_ICUUCBMC_LIB NAMES ${ARINSIDE_ARAPI_ICUUCBMC_LIBNAME} PATHS ${AR_INCLUDE_PATH}/lib)
241FIND_LIBRARY(ZLIB_LIB NAMES ${ZLIB_LIBNAMES} PATHS ${ZLIB_LIB_PATH})
242
243# check that necessary libs were found
244MESSAGE(STATUS "libar: (${ARINSIDE_ARAPI_LIB}) -- ${ARS_API_LIB}")
245IF (NOT ARS_API_LIB)
246        MESSAGE(FATAL_ERROR "Could not find ${ARINSIDE_ARAPI_LIB} in '${AR_INCLUDE_PATH}'! Please check or specify AR_INCLUDE_PATH variable")
247ENDIF (NOT ARS_API_LIB)
248
249IF (ARINSIDE_ENABLE_ZLIB_SUPPORT AND NOT ZLIB_LIB)
250        MESSAGE(FATAL_ERROR "Could not find ${ZLIB_LIBNAMES} in '${ZLIB_LIB_PATH}'! Please check or specify ZLIB_INCLUDE_PATH variable")
251ENDIF (ARINSIDE_ENABLE_ZLIB_SUPPORT AND NOT ZLIB_LIB)
252
253MESSAGE(STATUS "icudatabmc: (${ARINSIDE_ARAPI_ICUDATABMC_LIBNAME}) -- ${ARS_API_ICUDATABMC_LIB}")
254IF(ARS_API_ICUDATABMC_LIB)
255        LINK_LIBRARIES(${ARS_API_ICUDATABMC_LIB})
256ENDIF(ARS_API_ICUDATABMC_LIB)
257
258MESSAGE(STATUS "icui18nbmc: (${ARINSIDE_ARAPI_ICUI18NBMC_LIBNAME}) -- ${ARS_API_ICUI18NBMC_LIB}")
259IF(ARS_API_ICUI18NBMC_LIB)
260        LINK_LIBRARIES(${ARS_API_ICUI18NBMC_LIB})
261ENDIF(ARS_API_ICUI18NBMC_LIB)
262
263MESSAGE(STATUS "icuucbmc: (${ARINSIDE_ARAPI_ICUUCBMC_LIBNAME}) -- ${ARS_API_ICUUCBMC_LIB}")
264IF(ARS_API_ICUUCBMC_LIB)
265        LINK_LIBRARIES(${ARS_API_ICUUCBMC_LIB})
266ENDIF(ARS_API_ICUUCBMC_LIB)
267
268# now generate and import resources
269IF(UNIX)
270        IF(NOT DEFINED ARINSIDE_RESOURCES_ALREADY_BUILD)
271                INCLUDE_DIRECTORIES(${arinside_BINARY_DIR}/res)
272                FILE(MAKE_DIRECTORY ${arinside_BINARY_DIR}/res)
273                SET(ARINSIDE_GENERATED_RESOURCE_SRC_FILES "")
274                FOREACH(res ${ARINSIDE_RESOURCES})
275                        MESSAGE(STATUS "Generating ${res}.cpp ...")
276                        FILE(READ ${res} ARINSIDE_RES_OBJECT HEX)
277                        STRING(LENGTH ${ARINSIDE_RES_OBJECT} ARINSIDE_RES_OBJECT_LENGTH)
278                        SET(ARINSIDE_RES_OBJECT_CONTENT "")
279                        SET(ARINSIDE_RES_OBJECT_POSITION 0)
280                        WHILE(${ARINSIDE_RES_OBJECT_POSITION} LESS ${ARINSIDE_RES_OBJECT_LENGTH})
281                                STRING(SUBSTRING ${ARINSIDE_RES_OBJECT} ${ARINSIDE_RES_OBJECT_POSITION} 2 RES_CHAR)
282                                MATH(EXPR ARINSIDE_RES_OBJECT_POSITION "${ARINSIDE_RES_OBJECT_POSITION}+2")
283
284                                IF(NOT ${ARINSIDE_RES_OBJECT_CONTENT} STREQUAL "")
285                                        SET(ARINSIDE_RES_OBJECT_CONTENT "${ARINSIDE_RES_OBJECT_CONTENT},")
286                                ENDIF(NOT ${ARINSIDE_RES_OBJECT_CONTENT} STREQUAL "")
287
288                                SET(ARINSIDE_RES_OBJECT_CONTENT "${ARINSIDE_RES_OBJECT_CONTENT}0x${RES_CHAR}")
289                        ENDWHILE(${ARINSIDE_RES_OBJECT_POSITION} LESS ${ARINSIDE_RES_OBJECT_LENGTH})
290                       
291                        STRING(REGEX REPLACE "[^A-Za-z0-9]" "_" RES_OBJECT_NAME "${res}")
292                        SET(RES_OBJECT_NAME "_binary_${RES_OBJECT_NAME}")
293                        MATH(EXPR ARINSIDE_RES_REAL_OBJECT_LENGTH "${ARINSIDE_RES_OBJECT_LENGTH}/2")
294                        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")
295                       
296                        SET(RES_OUTPUT_NAME "${arinside_BINARY_DIR}/${res}.cpp")
297                        FILE(WRITE ${RES_OUTPUT_NAME} "${ARINSIDE_RES_OBJECT_CONTENT}")
298                       
299                        LIST(APPEND ARINSIDE_GENERATED_RESOURCE_SRC_FILES ${res}.cpp)
300                ENDFOREACH(res)
301                SET(ARINSIDE_RESOURCES_ALREADY_BUILD 1 CACHE INTERNAL "to remember resources are already build")
302                SET(ARINSIDE_GENERATED_RESOURCE_SRC_FILES ${ARINSIDE_GENERATED_RESOURCE_SRC_FILES} CACHE INTERNAL "to remember build source files")
303        ENDIF(NOT DEFINED ARINSIDE_RESOURCES_ALREADY_BUILD)
304        SET(ARINSIDE_SRCS ${ARINSIDE_SRCS} ${ARINSIDE_GENERATED_RESOURCE_SRC_FILES})
305ELSE(UNIX)
306        SET(ARINSIDE_SRCS ${ARINSIDE_SRCS} "ARInside.rc")
307        SET(ARINSIDE_MAIN_SRCS ${ARINSIDE_MAIN_SRCS} "ARInside.rc")
308ENDIF(UNIX)
309
310ADD_MSVC_PRECOMPILED_HEADER("stdafx.h" "stdafx.cpp" ARINSIDE_SRCS)
311
312# generate svnrev.h file
313FIND_PACKAGE(Subversion)
314IF(Subversion_FOUND)
315        Subversion_WC_INFO(${PROJECT_SOURCE_DIR} ARINSIDE)
316ELSE(Subversion_FOUND)
317        SET(ARINSIDE_WC_REVISION SVNMISS)
318ENDIF(Subversion_FOUND)
319FILE(READ ${PROJECT_SOURCE_DIR}/svnrev_template.h SVNREV_TEMPLATE)
320STRING(REPLACE "$WCREV$" ${ARINSIDE_WC_REVISION} SVNREV_TEMPLATE "${SVNREV_TEMPLATE}")
321FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/svnrev.h ${SVNREV_TEMPLATE})
322INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR})
323
324# now setup testing ... http://stackoverflow.com/questions/9689183/cmake-googletest
325INCLUDE(ExternalProject)
326SET_DIRECTORY_PROPERTIES(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/thirdparty)
327ExternalProject_Add(
328        googletest
329        URL http://googletest.googlecode.com/files/gtest-1.6.0.zip
330        TIMEOUT 10
331        # Force separate output paths for debug and release builds to allow easy
332        # identification of correct lib in subsequent TARGET_LINK_LIBRARIES commands
333        CMAKE_ARGS -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=DebugLibs
334                           -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=ReleaseLibs
335                           -Dgtest_force_shared_crt=ON
336        # Disable install step
337        INSTALL_COMMAND ""
338        # Wrap download, configure and build steps in a script to log output
339        ###These LOG_XXX params are only supported in cmake2.8.3+ and are disabled here to get backwards compatibility with 2.8.0
340        #LOG_DOWNLOAD ON
341        #LOG_CONFIGURE ON
342        #LOG_BUILD ON
343)
344       
345ExternalProject_Get_Property(googletest source_dir)
346INCLUDE_DIRECTORIES(${source_dir}/include)
347ExternalProject_Get_Property(googletest binary_dir)
348SET(GTEST_BINARY_DIR ${binary_dir})
349ENABLE_TESTING()
350
351LINK_DIRECTORIES(${GTEST_BINARY_DIR})
352
353# setup output target
354ADD_LIBRARY(arinsidelib ${ARINSIDE_SRCS} ${ARINSIDE_RESOURCE_OBJECTS})
355ADD_EXECUTABLE(arinside ${ARINSIDE_MAIN_SRCS})
356ADD_EXECUTABLE(arinsidetest ${ARINSIDE_TEST_SRCS})
357
358# dependencies
359ADD_DEPENDENCIES(arinsidetest arinsidelib googletest)
360ADD_DEPENDENCIES(arinside arinsidelib)
361
362# reference the needed libraries
363TARGET_LINK_LIBRARIES(arinside ${ARS_API_LIB} ${ZLIB_LIB} arinsidelib)
364TARGET_LINK_LIBRARIES(arinsidetest ${ARS_API_LIB} ${ZLIB_LIB} arinsidelib)
365IF(MSVC)
366        TARGET_LINK_LIBRARIES(arinsidetest
367                debug ${GTEST_BINARY_DIR}/DebugLibs/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_FIND_LIBRARY_SUFFIXES}
368                optimized ${GTEST_BINARY_DIR}/ReleaseLibs/${CMAKE_FIND_LIBRARY_PREFIXES}gtest${CMAKE_FIND_LIBRARY_SUFFIXES}
369        )
370ELSE(MSVC)
371        TARGET_LINK_LIBRARIES(arinsidetest gtest)
372ENDIF(MSVC)
373
374ADD_TEST(NAME test COMMAND arinsidetest)
375#INSTALL(TARGETS arinside DESTINATION bin)
Note: See TracBrowser for help on using the repository browser.