From 2a49897830b46889319985d9b1a1151fb2675a9f Mon Sep 17 00:00:00 2001 From: Victor Cebollada Date: Thu, 30 Jan 2020 07:23:31 +0000 Subject: [PATCH] CMake for MS Windows command line Change-Id: I6c1a60460fb9c19620e1e2dd7ac8258692b52649 Signed-off-by: Victor Cebollada --- README.md | 42 +++++++++++++++++++++++++++++++--- build/tizen/CMakeLists.txt | 57 ++++++++++++++++++++++++++++++---------------- 2 files changed, 77 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index b78598d..2e496c1 100644 --- a/README.md +++ b/README.md @@ -7,19 +7,20 @@ * [Minimum Requirements](#minimum-requirements) * [Creating a DALi Environment](#creating-a-dali-environment) * [Building the Repository](#building-the-repository) - * [Build target options](#build-target-options) * [Building and executing test cases](#building-and-executing-test-cases) * [2. GBS Builds](#2-gbs-builds) * [NON-SMACK Targets](#non-smack-targets) * [SMACK enabled Targets](#smack-enabled-targets) * [DEBUG Builds](#debug-builds) * [3. Building for MS Windows](#3-building-for-ms-windows) + * Build with the Visual Studio project. + * Build with CMake. # Build Instructions ## 1. Building for Ubuntu desktop -### Requirements +### Minimum Requirements - Ubuntu 14.04 or later - GCC version 6 @@ -101,4 +102,39 @@ vcpkg-script folder in the windows-dependencies repository. $ git clone https://github.com/dalihub/windows-dependencies.git -- Read the README.md and vcpkg-script/Readme.md files for more instructions on how to install and build the third-party dependencies. \ No newline at end of file +- Read the windows-dependencies/vcpkg-script/Readme.md file for more instructions on how to build and install the third-party dependencies. + +### Build with the Visual Studio project + Read the windows-dependencies/README.md file for more instructions on how to build and run DALi for MS Windows. + +### Build with CMake + + * Requirements + It's required the version 3.12.2 of CMake and a Git Bash Shell. + + * Notes and troubleshoting: + It should be possible to use the MS Visual studio Developer Command Prompt (https://docs.microsoft.com/en-us/dotnet/framework/tools/developer-command-prompt-for-vs) to build DALi from the command line. + However, the CMake version installed with MS Visual Studio 2017 is a bit out of date and some VCPKG modules require a higher version. + This instructions have been tested with CMake 3.12.2 on a Git Bash shell. + + * Define an environment variable to set the path to the VCPKG folder + + $ export VCPKG_FOLDER=C:/Users/username/Workspace/VCPKG_TOOL + + * Define an environment variable to set the path where DALi is going to be installed. + + $ export DALI_ENV_FOLDER=C:/Users/username/Workspace/dali-env + + * Execute the following commands to create the makefiles, build and install DALi. + + $ cmake -g Ninja . -DCMAKE_TOOLCHAIN_FILE=$VCPKG_FOLDER/vcpkg/scripts/buildsystems/vcpkg.cmake -DENABLE_PKG_CONFIGURE=OFF -DENABLE_LINK_TEST=OFF -DCMAKE_INSTALL_PREFIX=$DALI_ENV_FOLDER -DINSTALL_CMAKE_MODULES=ON + $ cmake --build . --target install + + + * Options: + - CMAKE_TOOLCHAIN_FILE ---> Needed to find packages installed by VCPKG. + - ENABLE_PKG_CONFIGURE ---> Whether to install pkg configure files (not currently working on MS Windows. CMake modules used instead). + - ENABLE_LINK_TEST ---> Whether to enable the link test (not currently working on MS Windows). + - CMAKE_INSTALL_PREFIX ---> Were DALi is installed. + - INSTALL_CMAKE_MODULES ---> Whether to install the CMake modules (Used by the CMake command find_package() to find previously installed libraries). + - ENABLE_DEBUG ---> Whether to build with debug enabled. diff --git a/build/tizen/CMakeLists.txt b/build/tizen/CMakeLists.txt index 367446c..ec60f6b 100644 --- a/build/tizen/CMakeLists.txt +++ b/build/tizen/CMakeLists.txt @@ -34,21 +34,22 @@ OPTION(ENABLE_LINK_TEST "Enable the link test" ON) IF( WIN32 ) # WIN32 includes x64 as well according to the cmake doc. FIND_PACKAGE( dali-windows-dependencies REQUIRED ) - FIND_PATH( SYSTEM_INCLUDE_DIR "dali-windows-dependencies.h" ) ENDIF() +SET( VCPKG_INCLUDE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include") + # Set up compiler definitions IF(CMAKE_BUILD_TYPE MATCHES Debug) - MESSAGE( STATUS "CMAKE_BUILD_TYPE: " Debug ) SET( ENABLE_DEBUG ON ) -ELSE() - MESSAGE( STATUS "CMAKE_BUILD_TYPE: " Release ) ENDIF() IF( ENABLE_DEBUG ) + MESSAGE( STATUS "CMAKE_BUILD_TYPE: " Debug ) ADD_DEFINITIONS( "-DDEBUG_ENABLED" ) SET( ENABLE_EXPORTALL ON ) +ELSE() + MESSAGE( STATUS "CMAKE_BUILD_TYPE: " Release ) ENDIF() IF( WIN32 ) # WIN32 includes x64 as well according to the cmake doc. @@ -69,10 +70,6 @@ ELSEIF( UNIX ) ADD_DEFINITIONS("-DTARGET") ENDIF() - IF( NOT ${ENABLE_EXPORTALL} ) - ADD_DEFINITIONS( "-fvisibility=hidden" ) - ENDIF() - ENDIF() IF( ENABLE_BACKTRACE OR ENABLE_LOCK_BACKTRACE ) @@ -107,17 +104,21 @@ IF( NOT INCLUDE_DIR ) ENDIF() # Set up the lib dir -IF( SET_VCPKG_INSTALL_PREFIX ) +SET( LIB_DIR $ENV{libdir} ) +IF( NOT LIB_DIR ) + SET( LIB_DIR ${CMAKE_INSTALL_LIBDIR} ) +ENDIF() +IF( NOT LIB_DIR ) SET( LIB_DIR ${PREFIX}/lib ) +ENDIF() + +# Set up the bin dir +SET( BIN_DIR $ENV{bindir} ) +IF( NOT BIN_DIR ) + SET( BIN_DIR ${CMAKE_INSTALL_BINDIR} ) +ENDIF() +IF( NOT BIN_DIR ) SET( BIN_DIR ${PREFIX}/bin ) -ELSE() - SET( LIB_DIR $ENV{libdir} ) - IF( NOT LIB_DIR ) - SET( LIB_DIR ${CMAKE_INSTALL_LIBDIR} ) - ENDIF() - IF( NOT LIB_DIR ) - SET( LIB_DIR ${PREFIX}/lib ) - ENDIF() ENDIF() IF( ENABLE_PKG_CONFIGURE ) @@ -133,6 +134,7 @@ IF( WIN32 ) # WIN32 includes x64 as well according to the cmake doc. ADD_COMPILE_OPTIONS( /FIdali-windows-dependencies.h ) # Adds missing definitions. ADD_COMPILE_OPTIONS( /vmg ) # Avoids a 'reinterpret_cast' compile error while compiling signals and callbacks. + ADD_COMPILE_OPTIONS( /wd4251 ) # Ignores warning C4251: "'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'" ELSEIF( UNIX ) @@ -154,11 +156,16 @@ ELSEIF( UNIX ) SET(COVERAGE --coverage) ENDIF() + IF( NOT ${ENABLE_EXPORTALL} ) + ADD_COMPILE_OPTIONS( "-fvisibility=hidden" ) + ENDIF() + ENDIF() INCLUDE_DIRECTORIES( ${ROOT_SRC_DIR} - ${SYSTEM_INCLUDE_DIR} + ${VCPKG_INCLUDE_DIR} + ${INCLUDE_DIR} ) SET(SOURCE_DIR "${ROOT_SRC_DIR}/dali") @@ -208,8 +215,13 @@ SET_TARGET_PROPERTIES( ${name} CLEAN_DIRECT_OUPUT 1 ) -# Install the library so file and symlinks IF( INSTALL_CMAKE_MODULES ) + IF( ENABLE_DEBUG ) + SET( BIN_DIR "${BIN_DIR}/debug" ) + SET( LIB_DIR "${LIB_DIR}/debug" ) + ENDIF() + + # Install the library files. INSTALL( TARGETS ${name} EXPORT ${name}-targets LIBRARY DESTINATION ${LIB_DIR} @@ -217,6 +229,7 @@ IF( INSTALL_CMAKE_MODULES ) RUNTIME DESTINATION ${BIN_DIR} ) + # Install the cmake modules. INSTALL( EXPORT ${name}-targets NAMESPACE ${name}:: @@ -229,7 +242,13 @@ IF( INSTALL_CMAKE_MODULES ) include(\${CMAKE_CURRENT_LIST_DIR}/${name}-targets.cmake) ") INSTALL( FILES ${CMAKE_CURRENT_BINARY_DIR}/${name}-config.cmake DESTINATION share/${name} ) + + # Install the pdb file. + IF( ENABLE_DEBUG ) + install( FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/${name}.pdb DESTINATION ${BIN_DIR} ) + ENDIF() ELSE() + # Install the library so file and symlinks. INSTALL( TARGETS ${name} DESTINATION ${LIB_DIR} ) ENDIF() -- 2.7.4