2018-03-01 00:41:55 +03:00
|
|
|
# Copyright (C) 2017 Microsoft. All rights reserved.
|
|
|
|
# See LICENSE file in the project root for full license information.
|
2017-10-20 04:17:46 +03:00
|
|
|
|
2017-10-20 03:08:56 +03:00
|
|
|
cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR)
|
2017-10-21 02:18:01 +03:00
|
|
|
SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
|
|
|
|
2017-10-30 23:04:28 +03:00
|
|
|
MESSAGE (STATUS "--------------------------------")
|
2018-02-14 00:25:38 +03:00
|
|
|
MESSAGE (STATUS "MSIX Packaging SDK")
|
2017-11-17 04:15:02 +03:00
|
|
|
MESSAGE (STATUS "--------------------------------")
|
2017-10-30 23:04:28 +03:00
|
|
|
|
2017-10-21 02:18:01 +03:00
|
|
|
# Set build options
|
2017-10-21 03:35:25 +03:00
|
|
|
OPTION(WIN32 "Build for Win32" OFF)
|
|
|
|
OPTION(MACOS "Build for MacOS" OFF)
|
|
|
|
OPTION(IOS "Build for iOS" OFF)
|
2017-10-21 02:18:01 +03:00
|
|
|
OPTION(AOSP "Build for Android" OFF)
|
|
|
|
OPTION(LINUX "Build for Linux" OFF)
|
|
|
|
|
2017-11-17 04:15:02 +03:00
|
|
|
# Default version is 0.0.0
|
|
|
|
SET(VERSION_MAJOR "0")
|
|
|
|
SET(VERSION_MINOR "0")
|
|
|
|
SET(VERSION_PATCH "0")
|
|
|
|
SET(GIT_BRANCH_NAME "master")
|
|
|
|
|
|
|
|
## Git (and its revision)
|
|
|
|
find_package(Git) # QUIET) # if we don't find git or FindGit.cmake is not on the system we ignore it.
|
|
|
|
|
|
|
|
## GetGitRevisionDescription module to retreive branch and revision information from Git
|
|
|
|
## Starting with Git 1.9 the module will be part of official cMake distribution, until then it has to be
|
|
|
|
## part of the application
|
|
|
|
## The Git module will trigger a reconfiguration for each pull that will bring a new revision on the local repository
|
|
|
|
SET(VCS_REVISION "-1")
|
|
|
|
IF(GIT_FOUND)
|
|
|
|
include(GetGitRevisionDescription)
|
|
|
|
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
|
|
|
|
MESSAGE(STATUS "GIT refspec ${GIT_REFSPEC}")
|
|
|
|
MESSAGE(STATUS "GIT revision ${GIT_SHA1}")
|
|
|
|
set (VCS_REVISION ${GIT_SHA1})
|
|
|
|
|
|
|
|
git_describe(GIT_DESCRIPTION)
|
|
|
|
MESSAGE(STATUS "GIT Description '${GIT_DESCRIPTION}'" )
|
|
|
|
string(REGEX MATCH "v([0-9]+)\\.([0-9]+)\\-([0-9]+)" _dummy1 "${GIT_DESCRIPTION}")
|
|
|
|
SET(VERSION_MAJOR ${CMAKE_MATCH_1})
|
|
|
|
SET(VERSION_MINOR ${CMAKE_MATCH_2})
|
|
|
|
SET(VERSION_PATCH ${CMAKE_MATCH_3})
|
|
|
|
|
|
|
|
IF(NOT VERSION_PATCH)
|
|
|
|
MESSAGE(STATUS "GIT Description is from NEW tag")
|
|
|
|
string(REGEX MATCH "v([0-9]+)\\.([0-9]+)" _dummy2 "${GIT_DESCRIPTION}")
|
|
|
|
SET(VERSION_MAJOR ${CMAKE_MATCH_1})
|
|
|
|
SET(VERSION_MINOR ${CMAKE_MATCH_2})
|
|
|
|
SET(VERSION_PATCH "0")
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
IF(NOT ${GIT_REFSPEC})
|
|
|
|
string(REGEX MATCH "refs/heads/([a-zA-Z0-9_/]+)" _dummy3 ${GIT_REFSPEC})
|
|
|
|
SET(GIT_BRANCH_NAME ${CMAKE_MATCH_1})
|
|
|
|
ELSE()
|
|
|
|
# VSO doesn't checkout a branch do a pull, it checks out a hash and does a pull
|
|
|
|
SET(GIT_BRANCH_NAME "master")
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
MESSAGE(STATUS "GIT branch name '${GIT_BRANCH_NAME}'" )
|
|
|
|
ELSE()
|
|
|
|
MESSAGE("git not found.")
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
# Set the version number of your project here (format is MAJOR.MINOR.PATCHLEVEL - e.g. 1.0.0)
|
|
|
|
SET(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
|
2018-02-14 00:25:38 +03:00
|
|
|
MESSAGE (STATUS "MSIX Packaging SDK version ${VERSION}")
|
|
|
|
MESSAGE (STATUS "MSIX Packaging SDK branch name ${GIT_BRANCH_NAME}")
|
2017-11-17 04:15:02 +03:00
|
|
|
|
|
|
|
# Configure Package.nuspec
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Package.nuspec.cmakein ${CMAKE_CURRENT_BINARY_DIR}/Package.nuspec CRLF)
|
2018-02-14 00:25:38 +03:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Microsoft.MSIX.Packaging.targets ${CMAKE_BINARY_DIR}/build/native/Microsoft.MSIX.Packaging.targets)
|
2017-11-17 04:15:02 +03:00
|
|
|
MESSAGE (STATUS "Package.Nuspec created")
|
|
|
|
MESSAGE (STATUS "--------------------------------")
|
|
|
|
|
2018-01-18 00:59:19 +03:00
|
|
|
# Configure license txt
|
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/LICENSE ${CMAKE_BINARY_DIR}/build/LICENSE)
|
|
|
|
MESSAGE (STATUS "LICENSE created")
|
|
|
|
MESSAGE (STATUS "--------------------------------")
|
|
|
|
|
|
|
|
# Configure certificates
|
|
|
|
# list each certificate by name that is to be published in the nuget package
|
|
|
|
LIST(APPEND CERTS_TO_PUBLISH
|
|
|
|
base64_MSFT_RCA_2010.cer
|
|
|
|
base64_MSFT_RCA_2011.cer
|
|
|
|
base64_STORE_PCA_2011.cer
|
|
|
|
base64_Windows_Production_PCA_2011.cer
|
|
|
|
base64_Windows_Production.cer
|
|
|
|
Microsoft_MarketPlace_PCA_2011.cer
|
|
|
|
)
|
|
|
|
FOREACH(CERT_TO_PUBLISH ${CERTS_TO_PUBLISH})
|
2018-03-07 03:45:39 +03:00
|
|
|
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/resources/certs/${CERT_TO_PUBLISH} ${CMAKE_BINARY_DIR}/build/certs/${CERT_TO_PUBLISH})
|
2018-01-18 00:59:19 +03:00
|
|
|
ENDFOREACH()
|
|
|
|
MESSAGE (STATUS "Certificates published")
|
|
|
|
MESSAGE (STATUS "--------------------------------")
|
|
|
|
|
2017-10-21 02:18:01 +03:00
|
|
|
# Enforce that target platform is specified.
|
2017-10-21 03:35:25 +03:00
|
|
|
IF((NOT WIN32) AND (NOT MACOS) AND (NOT IOS) AND (NOT AOSP) AND (NOT LINUX))
|
2017-10-30 23:04:28 +03:00
|
|
|
MESSAGE (STATUS "You must specify one of: [WIN32|MACOS|IOS|AOSP|LINUX]" )
|
|
|
|
MESSAGE (STATUS "For example, use cmake -DWIN32=on .." )
|
2017-10-21 02:18:01 +03:00
|
|
|
RETURN()
|
2017-10-30 23:04:28 +03:00
|
|
|
ELSE()
|
|
|
|
IF (WIN32)
|
|
|
|
MESSAGE (STATUS "Building for WIN32")
|
|
|
|
ENDIF()
|
|
|
|
IF (MACOS)
|
|
|
|
MESSAGE (STATUS "Building for MacOS")
|
|
|
|
ENDIF()
|
|
|
|
IF (IOS)
|
|
|
|
MESSAGE (STATUS "Building for iOS")
|
2018-01-13 05:53:15 +03:00
|
|
|
IF (IOS_DEPLOYMENT_TARGET VERSION_LESS 10.0)
|
|
|
|
MESSAGE(FATAL_ERROR "Unsupported iOS version: ${IOS_DEPLOYMENT_TARGET}, this project requires at least iOS version 10.0")
|
|
|
|
ENDIF()
|
|
|
|
SET(PLATFORM_APPLE 1)
|
2017-10-30 23:04:28 +03:00
|
|
|
ENDIF()
|
|
|
|
IF (AOSP)
|
|
|
|
MESSAGE (STATUS "Building for Android")
|
2017-12-12 23:50:36 +03:00
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
2017-10-30 23:04:28 +03:00
|
|
|
ENDIF()
|
|
|
|
IF (LINUX)
|
|
|
|
MESSAGE (STATUS "Building for Linux")
|
2017-11-14 04:44:06 +03:00
|
|
|
# Static libraries must be position independent to be linked with a shared object.
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
2017-10-30 23:04:28 +03:00
|
|
|
ENDIF()
|
|
|
|
ENDIF()
|
|
|
|
|
2018-03-06 00:41:56 +03:00
|
|
|
# Enforce parser PAL
|
2018-03-20 02:07:36 +03:00
|
|
|
IF(NOT USE_VALIDATION_PARSER)
|
|
|
|
MESSAGE (STATUS "To choose type of validation, Use the -DUSE_VALIDATION_PARSER=on to enable. Default is 'off'")
|
|
|
|
ENDIF()
|
|
|
|
|
2018-03-06 00:41:56 +03:00
|
|
|
IF(NOT XML_PARSER)
|
2018-03-06 04:51:10 +03:00
|
|
|
MESSAGE (STATUS "Choose the type of parser, options are: [xerces, msxml6]. Use the -DXML_PARSER=[option] to specify.")
|
|
|
|
INCLUDE(CheckIncludeFileCXX)
|
|
|
|
CHECK_INCLUDE_FILE_CXX(msxml6.h HAVE_MSXML6)
|
|
|
|
|
|
|
|
IF (HAVE_MSXML6)
|
|
|
|
SET(XML_PARSER msxml6 CACHE STRING "Using msxml6." FORCE)
|
|
|
|
ELSE()
|
|
|
|
SET(XML_PARSER xerces CACHE STRING "Using xerces" FORCE)
|
|
|
|
ENDIF()
|
2018-03-06 00:41:56 +03:00
|
|
|
ENDIF()
|
|
|
|
|
2017-10-30 23:04:28 +03:00
|
|
|
# Enforce build type
|
|
|
|
IF(NOT CMAKE_BUILD_TYPE)
|
2017-11-17 22:14:02 +03:00
|
|
|
SET(CMAKE_BUILD_TYPE Debug CACHE STRING
|
2017-11-02 11:23:17 +03:00
|
|
|
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel. Use the -DCMAKE_BUILD_TYPE=[option] to specify."
|
2017-10-30 23:04:28 +03:00
|
|
|
FORCE)
|
2017-10-21 02:18:01 +03:00
|
|
|
ENDIF()
|
|
|
|
|
2018-04-06 03:47:53 +03:00
|
|
|
# Enforce build libraries
|
|
|
|
IF(NOT USE_SHARED_ZLIB)
|
|
|
|
MESSAGE (STATUS "Choose the type of dependency of zlib, Use the -DUSE_SHARED_ZLIB=on to have a shared dependency. Default is 'off' (static)")
|
|
|
|
ENDIF()
|
|
|
|
|
2017-10-30 23:04:28 +03:00
|
|
|
MESSAGE (STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
|
|
|
|
2017-12-01 03:59:55 +03:00
|
|
|
IF ((CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) OR (CMAKE_BUILD_TYPE MATCHES Release) OR (CMAKE_BUILD_TYPE MATCHES MinSizeRel))
|
|
|
|
ADD_DEFINITIONS(-DNDEBUG)
|
|
|
|
MESSAGE (STATUS "NDEBUG defined, assert should be turned-off" )
|
|
|
|
ELSE()
|
|
|
|
MESSAGE (STATUS "NDEBUG NOT defined, assert should be turned-on" )
|
|
|
|
ENDIF()
|
|
|
|
|
|
|
|
|
2018-02-01 04:48:01 +03:00
|
|
|
IF((MACOS) OR (IOS))
|
2017-12-13 01:55:32 +03:00
|
|
|
if ((CMAKE_BUILD_TYPE MATCHES Release) OR (CMAKE_BUILD_TYPE MATCHES MinSizeRel))
|
2018-02-01 04:48:01 +03:00
|
|
|
MESSAGE (STATUS "optimized build, symbol generation turned-OFF" )
|
2017-12-13 01:55:32 +03:00
|
|
|
# on optimized builds, do NOT turn-on symbol generation.
|
|
|
|
else()
|
2018-02-01 04:48:01 +03:00
|
|
|
MESSAGE (STATUS "non-optimized build, symbol generation turned-ON" )
|
2017-12-13 01:55:32 +03:00
|
|
|
# Incredibly, for both clang and g++, while a single compile-and-link
|
|
|
|
# invocation will create an executable.dSYM/ dir with debug info,
|
|
|
|
# with separate compilation the final link does NOT create the
|
|
|
|
# dSYM dir.
|
|
|
|
# The "dsymutil" program will create the dSYM dir for us.
|
|
|
|
# Strangely it takes in the executable and not the object
|
|
|
|
# files even though it's the latter that contain the debug info.
|
|
|
|
# Thus it will only work if the object files are still sitting around.
|
|
|
|
find_program(DSYMUTIL_PROGRAM dsymutil)
|
|
|
|
if (DSYMUTIL_PROGRAM)
|
|
|
|
set(CMAKE_C_LINK_EXECUTABLE
|
|
|
|
"${CMAKE_C_LINK_EXECUTABLE}"
|
|
|
|
"${DSYMUTIL_PROGRAM} <TARGET>")
|
|
|
|
set(CMAKE_C_CREATE_SHARED_LIBRARY
|
|
|
|
"${CMAKE_C_CREATE_SHARED_LIBRARY}"
|
|
|
|
"${DSYMUTIL_PROGRAM} <TARGET>")
|
|
|
|
set(CMAKE_CXX_LINK_EXECUTABLE
|
|
|
|
"${CMAKE_CXX_LINK_EXECUTABLE}"
|
|
|
|
"${DSYMUTIL_PROGRAM} <TARGET>")
|
|
|
|
set(CMAKE_CXX_CREATE_SHARED_LIBRARY
|
|
|
|
"${CMAKE_CXX_CREATE_SHARED_LIBRARY}"
|
|
|
|
"${DSYMUTIL_PROGRAM} <TARGET>")
|
|
|
|
endif ()
|
|
|
|
endif()
|
2017-10-25 10:46:21 +03:00
|
|
|
ENDIF()
|
2017-10-20 04:17:46 +03:00
|
|
|
|
|
|
|
enable_testing() # needed on top-level CMakeLists.txt
|
|
|
|
|
|
|
|
# CMake useful variables
|
2017-10-21 02:18:01 +03:00
|
|
|
SET(CMAKE_PROJECT_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
|
|
|
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
|
|
|
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
2017-10-20 04:17:46 +03:00
|
|
|
|
2017-11-17 04:15:02 +03:00
|
|
|
# Mac needed variables
|
2017-10-20 04:17:46 +03:00
|
|
|
# [TODO: adapt as needed]
|
2017-10-21 02:18:01 +03:00
|
|
|
SET(CMAKE_MACOSX_RPATH ON)
|
|
|
|
#SET(CMAKE_SKIP_BUILD_RPATH FALSE)
|
|
|
|
#SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
|
|
|
|
#SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
|
|
|
|
#SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
2017-10-20 04:17:46 +03:00
|
|
|
|
|
|
|
add_subdirectory(lib)
|
2017-10-27 21:48:31 +03:00
|
|
|
MESSAGE (STATUS " ")
|
|
|
|
MESSAGE (STATUS "--------------------------------")
|
2018-02-14 00:25:38 +03:00
|
|
|
MESSAGE (STATUS "MSIX Packaging SDK")
|
2017-10-27 21:48:31 +03:00
|
|
|
MESSAGE (STATUS "--------------------------------")
|
|
|
|
MESSAGE (STATUS "libs processed")
|
2017-10-20 04:17:46 +03:00
|
|
|
add_subdirectory(src)
|
2017-10-27 21:48:31 +03:00
|
|
|
MESSAGE (STATUS "src processed")
|
2017-10-21 03:35:25 +03:00
|
|
|
ADD_DEPENDENCIES(SRC LIBS)
|
2017-10-27 21:48:31 +03:00
|
|
|
MESSAGE (STATUS "dependencies added")
|
2017-11-03 10:20:08 +03:00
|
|
|
add_subdirectory(sample)
|
|
|
|
MESSAGE (STATUS "sample processed")
|
2018-02-01 04:48:01 +03:00
|
|
|
add_subdirectory(test)
|
|
|
|
MESSAGE (STATUS "tests processed")
|
2017-10-27 21:48:31 +03:00
|
|
|
MESSAGE (STATUS "DONE!")
|