From 131a8fb17ff3abea3ab6a9a3d2c00206c3e31110 Mon Sep 17 00:00:00 2001 From: Adrian Del Grosso <10929341+ad3154@users.noreply.github.com> Date: Thu, 8 Jun 2023 18:05:16 -0600 Subject: [PATCH] Minor CMake enhancements Added some basic compiler checks to allow building with default MSVC using CMake. Added version and languages commands to CMake. Set library linkages to private, since they shouldn't be consumed directly by a consumer of this repo. --- CMakeLists.txt | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6aedd36..b97edd5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.24) set(CMAKE_POLICY_DEFAULT_CMP0091 NEW) -project(canal) +project(canal VERSION 1.0.5 LANGUAGES CXX C) set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 11) @@ -9,14 +9,18 @@ set(CMAKE_CXX_STANDARD 11) set(CMAKE_C_COMPILER) set(CMAKE_CXX_COMPILER) -#add_definitions(-DUNICODE) -#add_definitions(-D_UNICODE) -add_definitions(-D_MBCS) -add_definitions(-D_WIN32_WINNT_WIN10) +if(NOT MSVC) + #add_definitions(-DUNICODE) + #add_definitions(-D_UNICODE) + add_definitions(-D_MBCS) + add_definitions(-D_WIN32_WINNT_WIN10) +endif() -#add_compile_options(-Wall -Wextra -Wpedantic) -add_compile_options(-Wno-pragma-once-outside-header) -add_compile_options(-Wno-unused-parameter) +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + #add_compile_options(-Wall -Wextra -Wpedantic) + add_compile_options(-Wno-pragma-once-outside-header) + add_compile_options(-Wno-unused-parameter) +endif() if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") #add_compile_definitions(canal DEBUG_CANAL) @@ -42,7 +46,7 @@ add_library(canal SHARED set_property(TARGET canal PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded$<$:Debug>") -target_link_libraries(canal cfgmgr32 winusb) +target_link_libraries(canal PRIVATE cfgmgr32 winusb) set_target_properties(canal PROPERTIES OUTPUT_NAME "canal$<$:d>")