CMakeLists: fix general code styling, use dynamic linking on macOS

* Making the indentation even across the whole file
* Use dynamic linking on macOS and fix its pkg-config usage in the
process. This should render openFPGALoader agnostic to the
location of Homebrew's prefix, and solve compatibility issues with
MacPorts
This commit is contained in:
Jean THOMAS 2022-03-22 21:36:36 +01:00
parent 7d730eeeb6
commit c2b85f2a47
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)