Merge pull request #200 from jeanthom/dynamic-linking-macos

CMakeLists: fix general code styling, use dynamic linking on macOS
This commit is contained in:
Gwenhael Goavec-Merou 2022-03-23 06:32:38 +01:00 committed by GitHub
commit 3c258b9534
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 23 additions and 30 deletions

View File

@ -1,4 +1,3 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
# set the project name # set the project name
@ -159,6 +158,11 @@ set(OPENFPGALOADER_HEADERS
src/colognechipCfgParser.hpp src/colognechipCfgParser.hpp
) )
link_directories(
${LIBUSB_LIBRARY_DIRS}
${LIBFTDI_LIBRARY_DIRS}
)
add_executable(openFPGALoader add_executable(openFPGALoader
${OPENFPGALOADER_SOURCE} ${OPENFPGALOADER_SOURCE}
${OPENFPGALOADER_HEADERS} ${OPENFPGALOADER_HEADERS}
@ -169,16 +173,6 @@ include_directories(
${LIBFTDI_INCLUDE_DIRS} ${LIBFTDI_INCLUDE_DIRS}
) )
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
find_library(LIBFTDI1STATIC libftdi1.a REQUIRED)
find_library(LIBUSB1STATIC libusb-1.0.a REQUIRED)
target_link_libraries(openFPGALoader ${LIBFTDI1STATIC} ${LIBUSB1STATIC})
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -framework CoreFoundation -framework IOKit -framework Security")
link_directories(/usr/local/lib)
target_include_directories(openFPGALoader PRIVATE /usr/local/include)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
set_target_properties(openFPGALoader PROPERTIES LINK_SEARCH_END_STATIC 1)
else()
target_link_libraries(openFPGALoader target_link_libraries(openFPGALoader
${LIBUSB_LIBRARIES} ${LIBUSB_LIBRARIES}
${LIBFTDI_LIBRARIES} ${LIBFTDI_LIBRARIES}
@ -223,7 +217,6 @@ if (ZLIB_FOUND)
else() else()
message("zlib library not found: can't flash intel/altera devices") message("zlib library not found: can't flash intel/altera devices")
endif() endif()
endif()
if (LINK_CMAKE_THREADS) if (LINK_CMAKE_THREADS)
find_package(Threads REQUIRED) find_package(Threads REQUIRED)