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
|
|
|
|
2018-10-04 21:27:58 +03:00
|
|
|
cmake_minimum_required(VERSION 3.8.0 FATAL_ERROR)
|
2019-07-31 23:28:21 +03:00
|
|
|
project(msix-sdk)
|
2018-07-17 02:19:00 +03:00
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
2017-10-21 02:18:01 +03:00
|
|
|
|
2018-07-17 02:19:00 +03:00
|
|
|
message(STATUS "--------------------------------")
|
|
|
|
message(STATUS "MSIX Packaging SDK")
|
|
|
|
message(STATUS "--------------------------------")
|
2017-10-30 23:04:28 +03:00
|
|
|
|
2019-03-28 03:55:05 +03:00
|
|
|
message(STATUS "CMake version: ${CMAKE_VERSION}")
|
|
|
|
|
2018-10-04 21:27:58 +03:00
|
|
|
# specify that this binary is to be built with C++14
|
|
|
|
set(CMAKE_CXX_STANDARD 14)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
|
|
set(CMAKE_CXX_EXTENSIONS OFF)
|
|
|
|
|
2019-03-06 01:14:11 +03:00
|
|
|
# Support CMake 3.12. See https://cmake.org/cmake/help/latest/policy/CMP0077.html
|
|
|
|
if(POLICY CMP0077)
|
|
|
|
cmake_policy(SET CMP0077 NEW)
|
|
|
|
endif()
|
|
|
|
|
2017-11-17 04:15:02 +03:00
|
|
|
# Default version is 0.0.0
|
2018-07-17 02:19:00 +03:00
|
|
|
set(VERSION_MAJOR "0")
|
|
|
|
set(VERSION_MINOR "0")
|
|
|
|
set(VERSION_PATCH "0")
|
|
|
|
set(GIT_BRANCH_NAME "master")
|
2017-11-17 04:15:02 +03:00
|
|
|
|
2019-07-30 21:01:17 +03:00
|
|
|
# CMake useful variables
|
|
|
|
set(MSIX_PROJECT_ROOT ${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
set(MSIX_BINARY_ROOT ${CMAKE_CURRENT_BINARY_DIR})
|
|
|
|
|
|
|
|
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
|
|
|
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
|
|
|
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/lib")
|
|
|
|
|
2017-11-17 04:15:02 +03:00
|
|
|
## 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
|
2018-07-17 02:19:00 +03:00
|
|
|
set(VCS_REVISION "-1")
|
|
|
|
if(GIT_FOUND)
|
2017-11-17 04:15:02 +03:00
|
|
|
include(GetGitRevisionDescription)
|
|
|
|
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
|
2018-07-17 02:19:00 +03:00
|
|
|
message(STATUS "GIT refspec ${GIT_REFSPEC}")
|
|
|
|
message(STATUS "GIT revision ${GIT_SHA1}")
|
|
|
|
set(VCS_REVISION ${GIT_SHA1})
|
2017-11-17 04:15:02 +03:00
|
|
|
|
|
|
|
git_describe(GIT_DESCRIPTION)
|
2018-07-17 02:19:00 +03:00
|
|
|
message(STATUS "GIT Description '${GIT_DESCRIPTION}'" )
|
2017-11-17 04:15:02 +03:00
|
|
|
string(REGEX MATCH "v([0-9]+)\\.([0-9]+)\\-([0-9]+)" _dummy1 "${GIT_DESCRIPTION}")
|
2018-07-17 02:19:00 +03:00
|
|
|
set(VERSION_MAJOR ${CMAKE_MATCH_1})
|
|
|
|
set(VERSION_MINOR ${CMAKE_MATCH_2})
|
|
|
|
set(VERSION_PATCH ${CMAKE_MATCH_3})
|
2017-11-17 04:15:02 +03:00
|
|
|
|
2018-07-17 02:19:00 +03:00
|
|
|
if(NOT VERSION_PATCH)
|
|
|
|
message(STATUS "GIT Description is from NEW tag")
|
2017-11-17 04:15:02 +03:00
|
|
|
string(REGEX MATCH "v([0-9]+)\\.([0-9]+)" _dummy2 "${GIT_DESCRIPTION}")
|
2018-07-17 02:19:00 +03:00
|
|
|
set(VERSION_MAJOR ${CMAKE_MATCH_1})
|
|
|
|
set(VERSION_MINOR ${CMAKE_MATCH_2})
|
|
|
|
set(VERSION_PATCH "0")
|
|
|
|
endif()
|
2017-11-17 04:15:02 +03:00
|
|
|
|
2018-07-17 02:19:00 +03:00
|
|
|
if(NOT ${GIT_REFSPEC})
|
2017-11-17 04:15:02 +03:00
|
|
|
string(REGEX MATCH "refs/heads/([a-zA-Z0-9_/]+)" _dummy3 ${GIT_REFSPEC})
|
2018-07-17 02:19:00 +03:00
|
|
|
set(GIT_BRANCH_NAME ${CMAKE_MATCH_1})
|
|
|
|
else()
|
2017-11-17 04:15:02 +03:00
|
|
|
# VSO doesn't checkout a branch do a pull, it checks out a hash and does a pull
|
2018-07-17 02:19:00 +03:00
|
|
|
set(GIT_BRANCH_NAME "master")
|
|
|
|
endif()
|
2017-11-17 04:15:02 +03:00
|
|
|
|
2018-07-17 02:19:00 +03:00
|
|
|
message(STATUS "GIT branch name '${GIT_BRANCH_NAME}'" )
|
|
|
|
else()
|
|
|
|
message("git not found.")
|
|
|
|
endif()
|
2017-11-17 04:15:02 +03:00
|
|
|
|
|
|
|
# Set the version number of your project here (format is MAJOR.MINOR.PATCHLEVEL - e.g. 1.0.0)
|
2018-10-04 21:27:58 +03:00
|
|
|
set(MSIX_VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
|
|
|
|
message(STATUS "MSIX Packaging SDK version ${MSIX_VERSION}")
|
2018-07-17 02:19:00 +03:00
|
|
|
message(STATUS "MSIX Packaging SDK branch name ${GIT_BRANCH_NAME}")
|
2018-10-04 21:27:58 +03:00
|
|
|
add_definitions(-DSDK_VERSION="${MSIX_VERSION}")
|
2019-07-17 01:49:49 +03:00
|
|
|
# Validates CMake options.
|
|
|
|
include(msix_options)
|
2017-11-17 04:15:02 +03:00
|
|
|
|
|
|
|
# Configure Package.nuspec
|
2019-02-05 21:53:44 +03:00
|
|
|
if(WIN32)
|
|
|
|
set(MSIX_NUGET_NAME "Microsoft.MSIX.Packaging.Windows")
|
|
|
|
elseif(MACOS)
|
|
|
|
set(MSIX_NUGET_NAME "Microsoft.MSIX.Packaging.MacOS")
|
|
|
|
elseif(IOS)
|
|
|
|
set(MSIX_NUGET_NAME "Microsoft.MSIX.Packaging.iOS")
|
|
|
|
elseif(AOSP)
|
|
|
|
set(MSIX_NUGET_NAME "Microsoft.MSIX.Packaging.AOSP")
|
|
|
|
else()
|
2019-07-17 01:49:49 +03:00
|
|
|
set(MSIX_NUGET_NAME "Microsoft.MSIX.Packaging.Linux")
|
2019-02-05 21:53:44 +03:00
|
|
|
endif()
|
|
|
|
|
2019-07-31 23:28:21 +03:00
|
|
|
configure_file(${MSIX_PROJECT_ROOT}/Package.nuspec.cmakein ${MSIX_BINARY_ROOT}/Package.nuspec CRLF)
|
|
|
|
configure_file(${MSIX_PROJECT_ROOT}/Microsoft.MSIX.Packaging.targets ${MSIX_BINARY_ROOT}/build/native/${MSIX_NUGET_NAME}.targets)
|
2018-07-17 02:19:00 +03:00
|
|
|
message(STATUS "Package.Nuspec created")
|
|
|
|
message(STATUS "--------------------------------")
|
2017-11-17 04:15:02 +03:00
|
|
|
|
2018-01-18 00:59:19 +03:00
|
|
|
# Configure license txt
|
2019-07-31 23:28:21 +03:00
|
|
|
configure_file(${MSIX_PROJECT_ROOT}/LICENSE ${MSIX_BINARY_ROOT}/build/LICENSE)
|
|
|
|
configure_file(${MSIX_PROJECT_ROOT}/THIRD\ PARTY\ CODE\ NOTICE ${MSIX_BINARY_ROOT}/build/THIRD\ PARTY\ CODE\ NOTICE)
|
2018-07-17 02:19:00 +03:00
|
|
|
message(STATUS "LICENSE created")
|
2019-07-17 01:49:49 +03:00
|
|
|
message(STATUS "--------------------------------")
|
2018-01-18 00:59:19 +03:00
|
|
|
|
|
|
|
# Configure certificates
|
|
|
|
# list each certificate by name that is to be published in the nuget package
|
2018-07-17 02:19:00 +03:00
|
|
|
list(APPEND CERTS_TO_PUBLISH
|
2018-01-18 00:59:19 +03:00
|
|
|
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
|
|
|
|
)
|
2018-07-17 02:19:00 +03:00
|
|
|
foreach(CERT_TO_PUBLISH ${CERTS_TO_PUBLISH})
|
2019-07-31 23:28:21 +03:00
|
|
|
configure_file(${MSIX_PROJECT_ROOT}/resources/certs/${CERT_TO_PUBLISH} ${MSIX_BINARY_ROOT}/build/certs/${CERT_TO_PUBLISH})
|
2018-07-17 02:19:00 +03:00
|
|
|
endforeach()
|
|
|
|
message(STATUS "Certificates published")
|
2019-07-17 01:49:49 +03:00
|
|
|
message(STATUS "--------------------------------")
|
2018-07-17 02:19:00 +03:00
|
|
|
|
|
|
|
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
|
|
|
|
|
|
|
if((CMAKE_BUILD_TYPE MATCHES RelWithDebInfo) OR (CMAKE_BUILD_TYPE MATCHES Release) OR (CMAKE_BUILD_TYPE MATCHES MinSizeRel))
|
2017-12-01 03:59:55 +03:00
|
|
|
ADD_DEFINITIONS(-DNDEBUG)
|
2018-07-17 02:19:00 +03:00
|
|
|
message(STATUS "NDEBUG defined, assert should be turned-off" )
|
|
|
|
else()
|
|
|
|
message(STATUS "NDEBUG NOT defined, assert should be turned-on" )
|
|
|
|
endif()
|
2017-12-01 03:59:55 +03:00
|
|
|
|
2018-07-17 02:19:00 +03:00
|
|
|
if((MACOS) OR (IOS))
|
2018-04-18 19:35:41 +03:00
|
|
|
if ((CMAKE_BUILD_TYPE MATCHES Release) OR (CMAKE_BUILD_TYPE MATCHES MinSizeRel))
|
2018-07-17 02:19:00 +03:00
|
|
|
message(STATUS "optimized build, symbol generation turned-OFF" )
|
2018-04-18 19:35:41 +03:00
|
|
|
# on optimized builds, do NOT turn-on symbol generation.
|
|
|
|
else()
|
2018-07-17 02:19:00 +03:00
|
|
|
message(STATUS "non-optimized build, symbol generation turned-ON" )
|
2018-04-18 19:35:41 +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>")
|
2019-07-17 01:49:49 +03:00
|
|
|
endif()
|
2019-05-02 21:29:11 +03:00
|
|
|
endif()
|
2019-07-17 01:49:49 +03:00
|
|
|
if(IOS)
|
|
|
|
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()
|
2019-05-02 21:29:11 +03:00
|
|
|
endif()
|
2019-07-17 01:49:49 +03:00
|
|
|
elseif(AOSP OR LINUX)
|
|
|
|
# Static libraries must be position independent to be linked with a shared object.
|
|
|
|
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
|
2019-05-02 21:29:11 +03:00
|
|
|
endif()
|
|
|
|
|
2017-11-17 04:15:02 +03:00
|
|
|
# Mac needed variables
|
2017-10-20 04:17:46 +03:00
|
|
|
# [TODO: adapt as needed]
|
2018-07-17 02:19:00 +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)
|
2018-07-17 02:19:00 +03:00
|
|
|
message(STATUS "libs processed")
|
2017-10-20 04:17:46 +03:00
|
|
|
add_subdirectory(src)
|
2018-07-17 02:19:00 +03:00
|
|
|
message(STATUS "src processed")
|
2019-10-15 04:11:19 +03:00
|
|
|
if (MSIX_SAMPLES)
|
|
|
|
add_subdirectory(sample)
|
|
|
|
message(STATUS "sample processed")
|
|
|
|
endif()
|
2018-07-17 02:19:00 +03:00
|
|
|
message(STATUS "DONE!")
|