winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

CMakeLists.txt (2663B)


      1 # Copyright (c) Microsoft Corporation.
      2 # Licensed under the MIT License.
      3 
      4 cmake_minimum_required(VERSION 3.19)
      5 
      6 # Tell CMake to look in cmake for our custom CMake module files.
      7 set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
      8 
      9 include(SFSOptions)
     10 
     11 if(SFS_BUILD_TESTS)
     12     list(APPEND VCPKG_MANIFEST_FEATURES "tests")
     13 endif()
     14 
     15 set(CMAKE_TOOLCHAIN_FILE "vcpkg/scripts/buildsystems/vcpkg.cmake")
     16 
     17 # By default using x64 static custom triplet for Windows. Can be overridden by
     18 # setting VCPKG_TARGET_TRIPLET
     19 if(SFS_WINDOWS_STATIC_ONLY
     20    AND WIN32
     21    AND NOT DEFINED VCPKG_TARGET_TRIPLET)
     22     set(VCPKG_TARGET_TRIPLET "x64-windows-static-custom")
     23 endif()
     24 
     25 # Semver versioning. Given MAJOR.MINOR.PATCH, increment the:
     26 #
     27 # 1. MAJOR version when you make incompatible API changes
     28 # 2. MINOR version when you add functionality in a backward compatible manner
     29 # 3. PATCH version when you make backward compatible bug fixes
     30 set(SFS_LIBRARY_VERSION "1.1.0")
     31 
     32 project(
     33     sfsclient
     34     VERSION ${SFS_LIBRARY_VERSION}
     35     LANGUAGES CXX)
     36 
     37 set(CMAKE_CXX_STANDARD 17)
     38 set(CMAKE_CXX_STANDARD_REQUIRED True)
     39 
     40 # Use this function to set warning level and warnings as errors for a given
     41 # target
     42 function(set_compile_options_for_target target)
     43     if(MSVC)
     44         # Enable some MSVC warnings that are off by default:
     45         #
     46         # * 4062: all enums are handled in switch statements without a default
     47         #   label
     48         # * 4191: unsafe conversion from 'type of expression' to 'type required'
     49         # * 4242: possible loss of data (identifier)
     50         # * 4254: possible loss of data (operator)
     51         # * 4287: 'operator': unsigned/negative constant mismatch
     52         # * 4296: 'operator': expression is always true (or false)
     53         # * 4388: signed/unsigned mismatch
     54         # * 4800: implicit conversion to bool; possible information loss
     55         # * 4946: reinterpret_cast used between related classes
     56 
     57         # cmake-format: off
     58         target_compile_options(${target} PRIVATE /W4 /WX /we4062 /we4191 /we4242 /we4254 /we4287 /we4296 /we4388 /we4800 /we4946)
     59         # cmake-format: on
     60     else()
     61         target_compile_options(
     62             ${target}
     63             PRIVATE -Wall
     64                     -Wextra
     65                     -Wpedantic
     66                     -Werror)
     67     endif()
     68 endfunction()
     69 
     70 if(SFS_WINDOWS_STATIC_ONLY AND MSVC)
     71     # For MSVC, use a multi-threaded statically-linked runtime library
     72     set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
     73 endif()
     74 
     75 add_subdirectory(client)
     76 
     77 if(SFS_BUILD_SAMPLES)
     78     add_subdirectory(samples)
     79 endif()