fix vcpkg build
authoralfadur
Sat, 08 Apr 2023 01:42:26 +0300
changeset 15977 3199bbfeba31
parent 15976 69479ac8f4c8
child 15978 4ec24af5909a
fix vcpkg build
CMakeLists.txt
QTfrontend/CMakeLists.txt
hedgewars/CMakeLists.txt
--- a/CMakeLists.txt	Sat Apr 08 01:23:47 2023 +0300
+++ b/CMakeLists.txt	Sat Apr 08 01:42:26 2023 +0300
@@ -177,6 +177,7 @@
                               "-fno-warn-unused-do-bind"
                               "-O0"
                               )
+    set(USE_DEBUG_LIBRARIES TRUE)
 else()
     list(APPEND haskell_flags "-w" # no warnings
                               "-O2"
@@ -249,7 +250,15 @@
 if(PHYSFS_LIBRARY AND PHYSFS_INCLUDE_DIR)
     #use an IMPORTED tharget so that we can just use 'physfs' to link
     add_library(physfs UNKNOWN IMPORTED)
-    set_target_properties(physfs PROPERTIES IMPORTED_LOCATION ${PHYSFS_LIBRARY})
+    if (DEFINED PHYSFS_LIBRARY_RELEASE)
+        if (${USE_DEBUG_LIBRARIES})
+            set_target_properties(physfs PROPERTIES IMPORTED_LOCATION ${PHYSFS_LIBRARY_DEBUG})
+        else()    
+            set_target_properties(physfs PROPERTIES IMPORTED_LOCATION ${PHYSFS_LIBRARY_RELEASE})
+        endif()
+    else()
+        set_target_properties(physfs PROPERTIES IMPORTED_LOCATION ${PHYSFS_LIBRARY})
+    endif()
 else()
     message(FATAL_ERROR "Missing PhysFS! Install PhysFS to fix this.")
 endif()
--- a/QTfrontend/CMakeLists.txt	Sat Apr 08 01:23:47 2023 +0300
+++ b/QTfrontend/CMakeLists.txt	Sat Apr 08 01:42:26 2023 +0300
@@ -14,7 +14,7 @@
 include(CheckLibraryExists)
 
 find_package(SDL2 REQUIRED CONFIG)
-find_package(SDL2_mixer 2 REQUIRED) #audio in SDLInteraction
+find_package(SDL2_mixer REQUIRED CONFIG) #audio in SDLInteraction
 include_directories(${SDL2_INCLUDE_DIRS})
 include_directories(${SDL2_MIXER_INCLUDE_DIRS})
 
@@ -229,16 +229,13 @@
     Qt5::Core Qt5::Widgets Qt5::Gui Qt5::Network
     )
 
-list(APPEND HW_LINK_LIBS
-    ${SDL2_LIBRARIES}
-    ${SDL2_MIXER_LIBRARIES}
-    )
+if(WIN32 AND VCPKG_TOOLCHAIN)
+    list(APPEND HW_LINK_LIBS SDL2::SDL2 SDL2_mixer::SDL2_mixer)
+else()  
+    list(APPEND HW_LINK_LIBS ${SDL2_LIBRARIES} ${SDL2_MIXER_LIBRARIES})
+endif() 
 
 if(WIN32 AND NOT UNIX)
-    if(NOT SDL2_LIBRARIES)
-        list(APPEND HW_LINK_LIBS SDL2::SDL2)
-    endif()
-
     list(APPEND HW_LINK_LIBS
         ole32
         oleaut32
--- a/hedgewars/CMakeLists.txt	Sat Apr 08 01:23:47 2023 +0300
+++ b/hedgewars/CMakeLists.txt	Sat Apr 08 01:42:26 2023 +0300
@@ -1,10 +1,10 @@
 enable_language(Pascal)
 
 find_package(SDL2 REQUIRED CONFIG)
-find_package(SDL2_image 2 REQUIRED)
-find_package(SDL2_net 2 REQUIRED)
-find_package(SDL2_ttf 2 REQUIRED)
-find_package(SDL2_mixer 2 REQUIRED)
+find_package(SDL2_image REQUIRED CONFIG)
+find_package(SDL2_net REQUIRED CONFIG)
+find_package(SDL2_ttf REQUIRED CONFIG)
+find_package(SDL2_mixer REQUIRED CONFIG)
 
 include(CheckLibraryExists)
 include(${CMAKE_MODULE_PATH}/utils.cmake)
@@ -168,8 +168,18 @@
 endif()
 
 # PhysFS
-get_filename_component(PHYSFS_LIBRARY_DIR ${PHYSFS_LIBRARY} PATH)
-add_flag_append(CMAKE_Pascal_FLAGS "-Fl${PHYSFS_LIBRARY}")
+if (DEFINED PHYSFS_LIBRARY_RELEASE)
+    if(${USE_DEBUG_LIBRARIES})
+        get_filename_component(PHYSFS_LIBRARY_DIR ${PHYSFS_LIBRARY_DEBUG} PATH)
+        add_flag_append(CMAKE_Pascal_FLAGS "-Fl${PHYSFS_LIBRARY_DEBUG}")
+    else()    
+        get_filename_component(PHYSFS_LIBRARY_DIR ${PHYSFS_LIBRARY_RELEASE} PATH)
+        add_flag_append(CMAKE_Pascal_FLAGS "-Fl${PHYSFS_LIBRARY_RELEASE}")
+    endif()
+else()
+    get_filename_component(PHYSFS_LIBRARY_DIR ${PHYSFS_LIBRARY} PATH)
+    add_flag_append(CMAKE_Pascal_FLAGS "-Fl${PHYSFS_LIBRARY}")
+endif()
 
 list(APPEND HW_LINK_LIBS physlayer)