libftdi Archives

Subject: [PATCH 10/10] cmake: fix building static lib on windows/msvc include(GNUInstallDirs) is required to populate CMAKE_INSTALL_LIBDIR

From: Shawn Hoffman <business@xxxxxxxxxxxx>
To: libftdi@xxxxxxxxxxxxxxxxxxxxxxx
Cc: Shawn Hoffman <godisgovernment@xxxxxxxxx>
Date: Wed, 10 Apr 2024 07:15:49 -0700
From: Shawn Hoffman <godisgovernment@xxxxxxxxx>

---
 CMakeLists.txt     | 7 ++++++-
 src/CMakeLists.txt | 1 -
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6a0f53f..ad49b11 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,6 +37,8 @@ endif("${CMAKE_BUILD_TYPE}" STREQUAL "")
 
 set(CMAKE_COLOR_MAKEFILE ON)
 
+include(GNUInstallDirs)
+
 add_definitions(-Wall)
 
 include(CMakeOptions.txt)
@@ -176,6 +178,9 @@ endif(${UNIX})
 
 if(${WIN32})
   set(libdir ${CMAKE_INSTALL_PREFIX}/bin)
+  if(STATICLIBS)
+    list(APPEND libdir ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR})
+  endif()
 endif(${WIN32})
 
 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/libftdi1.pc.in 
${CMAKE_CURRENT_BINARY_DIR}/libftdi1.pc @ONLY)
@@ -199,7 +204,7 @@ set(LIBFTDI_INCLUDE_DIRS ${LIBFTDI_INCLUDE_DIR})
 set(LIBFTDI_LIBRARY ftdi1)
 set(LIBFTDI_LIBRARIES ${LIBFTDI_LIBRARY})
 list(APPEND LIBFTDI_LIBRARIES ${LIBUSB_LIBRARIES})
-set(LIBFTDI_STATIC_LIBRARY ftdi1.a)
+set(LIBFTDI_STATIC_LIBRARY ftdi1-static)
 set(LIBFTDI_STATIC_LIBRARIES ${LIBFTDI_STATIC_LIBRARY})
 list(APPEND LIBFTDI_STATIC_LIBRARIES ${LIBUSB_LIBRARIES})
 
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index c0c4909..826cb7d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -70,7 +70,6 @@ install(TARGETS ftdi1
 if(STATICLIBS)
   add_library(ftdi1-static STATIC ${c_sources})
   target_link_libraries(ftdi1-static ${LIBUSB_LIBRARIES})
-  set_target_properties(ftdi1-static PROPERTIES OUTPUT_NAME "ftdi1")
   set_target_properties(ftdi1-static PROPERTIES CLEAN_DIRECT_OUTPUT 1)
   install(TARGETS ftdi1-static
     ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
-- 
2.44.0.windows.1


--
libftdi - see http://www.intra2net.com/en/developer/libftdi for details.
To unsubscribe send a mail to libftdi+unsubscribe@xxxxxxxxxxxxxxxxxxxxxxx   

Current Thread