CMake for MS Windows command line 55/224155/17
authorVictor Cebollada <v.cebollada@samsung.com>
Thu, 6 Feb 2020 10:52:50 +0000 (10:52 +0000)
committerVictor Cebollada <v.cebollada@samsung.com>
Tue, 14 Apr 2020 20:44:14 +0000 (21:44 +0100)
Change-Id: If41d0394d5c98e124be9decf813d754e8f46c9a3
Signed-off-by: Victor Cebollada <v.cebollada@samsung.com>
README.md
build/tizen/CMakeLists.txt
build/tizen/profiles/windows-profile.cmake

index cc06c82..99a47a6 100644 (file)
--- a/README.md
+++ b/README.md
          * [Building and executing test cases](#building-and-executing-test-cases)
       * [2. GBS Builds](#2-gbs-builds)
          * [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
  - Environment created using dali_env script in dali-core repository
@@ -54,3 +57,50 @@ See the README.md in dali-adaptor/automated-tests.
 ### DEBUG Builds
 
          $ gbs build -A [TARGET_ARCH] --define "%enable_debug 1"
+
+
+## 3. Building for MS Windows
+
+Third party dependencies are built using vcpkg. Instructions on how to install vcpkg can be found in the
+vcpkg-script folder in the windows-dependencies repository.
+
+- Download the windows-dependencies repository from DaliHub
+
+         $ git clone https://github.com/dalihub/windows-dependencies.git
+
+- 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 -DPROFILE_LCASE=windows
+    $ 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).
+    - PROFILE_LCASE         ---> The platform (must be windows).
+    - ENABLE_DEBUG          ---> Whether to build with debug enabled.
index fd6681a..91381a8 100644 (file)
@@ -49,9 +49,10 @@ SET(DALI_ADAPTOR_VERSION ${${name}_VERSION} )
 IF( WIN32 ) # WIN32 includes x64 as well according to the cmake doc.
   FIND_PACKAGE( dali-windows-dependencies REQUIRED)
   FIND_PACKAGE( dali-core REQUIRED)
-  FIND_PATH( SYSTEM_INCLUDE_DIR "dali-windows-dependencies.h" )
 ENDIF()
 
+SET( VCPKG_INCLUDE_DIR "${_VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include")
+
 IF( UNIX )
   ADD_DEFINITIONS(-DPLATFORM_TIZEN)
   ADD_DEFINITIONS(-DPIC -DSTDC_HEADERS)
@@ -82,17 +83,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( UNIX )
@@ -107,7 +112,7 @@ ELSEIF( WIN32 ) # WIN32 includes x64 as well according to the cmake doc.
   ADD_COMPILE_OPTIONS( /FIextern-definitions.h )        # Adds missing definitions.
   ADD_COMPILE_OPTIONS( /FIpreprocessor-definitions.h )  #
   ADD_COMPILE_OPTIONS( /vmg )                           # Avoids a 'reinterpret_cast' compile error while compiling signals and callbacks.
-  ADD_COMPILE_OPTIONS( /TP )                            # All files considered C++
+  ADD_COMPILE_OPTIONS( /wd4251 )                        # Ignores warning C4251: "'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'"
 ENDIF()
 
 ADD_DEFINITIONS( -DNON_POWER_OF_TWO_TEXTURES
@@ -152,7 +157,8 @@ INCLUDE_DIRECTORIES(
   ${ROOT_SRC_DIR}
   ${PROFILE_INCLUDE_DIRECTORIES}
   ${THIRD_PARTY_WINDOWS_PLATFORM}
-  ${SYSTEM_INCLUDE_DIR}
+  ${VCPKG_INCLUDE_DIR}
+  ${INCLUDE_DIR}
 )
 
 SET(LIBTYPE SHARED)
@@ -184,8 +190,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}
@@ -193,6 +204,7 @@ IF( INSTALL_CMAKE_MODULES )
     RUNTIME DESTINATION ${BIN_DIR}
   )
 
+  # Install the cmake modules.
   INSTALL(
     EXPORT ${name}-targets
     NAMESPACE ${name}::
@@ -205,7 +217,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()
 
@@ -384,6 +402,7 @@ MESSAGE( STATUS "Use pkg configure:                ${ENABLE_PKG_CONFIGURE}" )
 MESSAGE( STATUS "Enable link test:                 ${ENABLE_LINK_TEST}" )
 MESSAGE( STATUS "Tizen Platform Config supported   ${TIZEN_PLATFORM_CONFIG_SUPPORTED_LOGMSG}")
 MESSAGE( STATUS "Compile flags:                    ${CMAKE_CXX_FLAGS}")
+MESSAGE( STATUS "Compile flags:                    ${CMAKE_C_FLAGS}")
 IF( enable_feedback )
   ADD_SUBDIRECTORY( plugins )
 ENDIF()
index 1d11354..b190e23 100644 (file)
@@ -42,6 +42,9 @@ SET( SOURCES
         ${adaptor_imaging_windows_src_files}
 )
 
+# Builds the c files as c++
+SET_SOURCE_FILES_PROPERTIES( ${static_libraries_libunibreak_src_files} PROPERTIES LANGUAGE CXX )
+
 FIND_PACKAGE( pthreads REQUIRED )
 FIND_PACKAGE( curl REQUIRED )
 FIND_LIBRARY( GETOPT_LIBRARY NAMES getopt )
@@ -52,7 +55,7 @@ FIND_PACKAGE( gif REQUIRED )
 FIND_PACKAGE( jpeg REQUIRED )
 FIND_LIBRARY( TURBO_JPEG_LIBRARY NAMES turbojpeg )
 
-FIND_PACKAGE( fontconfig REQUIRED )
+FIND_PACKAGE( unofficial-fontconfig REQUIRED )
 FIND_PACKAGE( freetype REQUIRED )
 FIND_PACKAGE( harfbuzz REQUIRED )
 FIND_LIBRARY( FRIBIDI_LIBRARY NAMES fribidi )
@@ -70,7 +73,7 @@ SET( REQUIRED_LIBS
         ${GIF_LIBRARIES}
         JPEG::JPEG
         ${TURBO_JPEG_LIBRARY}
-        ${FONTCONFIG_LIBRARIES}
+        unofficial::fontconfig::fontconfig
         Freetype::Freetype
         harfbuzz::harfbuzz
         ${FRIBIDI_LIBRARY}