From eb49d75d1a1f5c63c32e6140dc98d52ac4b351a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zdenko=20Podobn=C3=BD?= Date: Fri, 19 May 2023 11:52:19 +0200 Subject: [PATCH 1/3] cmake: remove CXX from project, fix msvc 2019 build, use C17 standard --- CMakeLists.txt | 4 +++- prog/CMakeLists.txt | 3 --- src/CMakeLists.txt | 7 ++++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5350215ad..dbfe70be3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,8 +41,10 @@ set_property(GLOBAL PROPERTY PREDEFINED_TARGETS_FOLDER "CMake Targets") project( leptonica - LANGUAGES C CXX + LANGUAGES C VERSION 1.84.0) +set(CMAKE_C_STANDARD 17) +set(CMAKE_C_STANDARD_REQUIRED ON) set(MINIMUM_WEBPMUX_VERSION 0.5.0) diff --git a/prog/CMakeLists.txt b/prog/CMakeLists.txt index be82d8c64..6eff468be 100644 --- a/prog/CMakeLists.txt +++ b/prog/CMakeLists.txt @@ -3,9 +3,6 @@ ######################################## function(add_prog_target target) set (${target}_src "${ARGN}") - if (WIN32) - set_source_files_properties (${${target}_src} PROPERTIES LANGUAGE CXX) - endif() add_executable (${target} ${${target}_src}) if (BUILD_SHARED_LIBS) target_compile_definitions (${target} PRIVATE -DLIBLEPT_IMPORTS) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 651185087..e8bf771e6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,9 +10,6 @@ file(GLOB hdr "*.h") file(GLOB src "*.c") -if (MSVC) - set_source_files_properties(${src} PROPERTIES LANGUAGE CXX) -endif() string(REPLACE "-O3" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") @@ -73,6 +70,10 @@ if (UNIX) endif(SYM_LINK) endif() +if (MSVC) + target_link_libraries (leptonica PRIVATE user32.lib gdi32.lib) +endif() + if (NOT SW_BUILD) export(TARGETS leptonica FILE ${CMAKE_BINARY_DIR}/LeptonicaTargets.cmake) else() From 5da64d800dd7c6b6ea60f35d415582ef62d75b5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zdenko=20Podobn=C3=BD?= Date: Fri, 19 May 2023 11:52:56 +0200 Subject: [PATCH 2/3] cmake windows: fix not found gif_lib.h --- prog/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/prog/CMakeLists.txt b/prog/CMakeLists.txt index 6eff468be..61b1e9522 100644 --- a/prog/CMakeLists.txt +++ b/prog/CMakeLists.txt @@ -4,6 +4,11 @@ function(add_prog_target target) set (${target}_src "${ARGN}") add_executable (${target} ${${target}_src}) + string(FIND ${target} "gif" GIF_TEST_FOUND) + if (GIF_TEST_FOUND EQUAL 0) + # gif_lib.h is not found on Windows + target_include_directories (${target} PRIVATE ${GIF_INCLUDE_DIR}) + endif() if (BUILD_SHARED_LIBS) target_compile_definitions (${target} PRIVATE -DLIBLEPT_IMPORTS) endif() From 9199e623ed5b280e1989cd8e8d515abae23bb0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zdenko=20Podobn=C3=BD?= Date: Fri, 19 May 2023 11:57:15 +0200 Subject: [PATCH 3/3] cmake: +include(GNUInstallDirs) --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index dbfe70be3..2859e425a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,9 @@ project( set(CMAKE_C_STANDARD 17) set(CMAKE_C_STANDARD_REQUIRED ON) +# Standard installation paths +include(GNUInstallDirs) + set(MINIMUM_WEBPMUX_VERSION 0.5.0) option(BUILD_PROG "Build utility programs" OFF)