Skip to content

Commit

Permalink
Fix Linux compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
robbr48 committed Oct 22, 2024
1 parent 71c1e22 commit b1ecd0a
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 12 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ jobs:
- name: Install Packages
run: |
sudo apt-get update
sudo apt-get install qt5-default qtbase5-dev qtbase5-private-dev libqt5webkit5-dev libqt5svg5-dev libqt5opengl5-dev libhdf5-dev libmarkdown2-dev libmsgpack-dev libqwt-qt5-dev libzmq3-dev zlib1g
sudo apt-get install qt5-default qtbase5-dev qtbase5-private-dev libqt5webkit5-dev libqt5svg5-dev libqt5opengl5-dev libhdf5-dev libmarkdown2-dev libmsgpack-dev libqwt-qt5-dev libzmq3-dev zlib1g libzip-dev zipcmp ziptool zipmerge
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -88,7 +88,7 @@ jobs:
- name: Download dependencies
shell: bash
working-directory: dependencies
run: ./download-dependencies.py fmilibrary tclap fmi4c xerces asio libzip dcplib
run: ./download-dependencies.py fmilibrary tclap fmi4c xerces asio dcplib

- name: Build dependencies
shell: bash
Expand All @@ -98,7 +98,6 @@ jobs:
./setupTclap.sh
./setupFmi4c.sh
./setupXerces.sh
./setupLibzip.sh
./setupDCPLib.sh
- name: Configure
Expand Down
23 changes: 18 additions & 5 deletions dependencies/libzip.cmake
Original file line number Diff line number Diff line change
@@ -1,19 +1,32 @@
set(local_libzip_dir ${CMAKE_CURRENT_LIST_DIR}/libzip)
find_library(libzip NAMES libzip PATHS ${local_libzip_dir}/lib)
if(WIN32)
set(CMAKE_FIND_LIBRARY_PREFIXES lib)
endif(WIN32)
find_library(libzip NAMES ${CMAKE_FIND_LIBRARY_PREFIXES}zip ${CMAKE_FIND_LIBRARY_PREFIXES}zip${CMAKE_SHARED_LIBRARY_SUFFIX} PATHS ${local_libzip_dir}/lib)

message("looking for ${CMAKE_FIND_LIBRARY_PREFIXES}zip${CMAKE_SHARED_LIBRARY_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}")

if (libzip)
message(STATUS "Found local libzip")
add_library(libzip STATIC IMPORTED)
set_target_properties(libzip PROPERTIES
IMPORTED_LOCATION ${local_libzip_dir}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}libzip${CMAKE_SHARED_LIBRARY_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
INTERFACE_INCLUDE_DIRECTORIES ${local_libzip_dir}/include)
if (WIN32)
set_target_properties(libzip PROPERTIES
IMPORTED_LOCATION ${local_libzip_dir}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}zip${CMAKE_SHARED_LIBRARY_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
INTERFACE_INCLUDE_DIRECTORIES ${local_libzip_dir}/include)
else()
set_target_properties(libzip PROPERTIES
IMPORTED_LOCATION ${local_libzip_dir}/lib/libzip.so
INTERFACE_INCLUDE_DIRECTORIES ${local_libzip_dir}/include)
endif()

else()
message(STATUS "Looking for libzip in system")
set(CMAKE_FIND_DEBUG_MODE TRUE)
find_package(libzip CONFIG) # Search in system
set(CMAKE_FIND_DEBUG_MODE FALSE)
if (libzip_FOUND)
message(STATUS "Found libzip")
add_library(libzip INTERFACE)
add_library(libzip STATIC IMPORTED)
else()
message(WARNING "Could not find libzip")
endif()
Expand Down
2 changes: 1 addition & 1 deletion dependencies/setupDCPLib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ mkdir -p $builddir
cd $builddir

# Generate makefiles
cmake -Wno-dev -DLOGGING=ON -DASIO_ROOT=${basedir}/asio-code -DXercesC_LIBRARY=${xercesdir}/bin/libxerces-c -DXercesC_INCLUDE_DIR=${xercesdir}/include -DXercesC_VERSION="3.2.2" -DZIP_LIBRARY=${basedir}/libzip/bin/libzip -DZIP_INCLUDE_DIR=${basedir}/libzip/include -DCMAKE_INSTALL_PREFIX=${installdir} ${codedir}
cmake -Wno-dev -DLOGGING=ON -DASIO_ROOT="${basedir}/asio-code" -DXercesC_LIBRARY="${xercesdir}/bin/libxerces-c" -DXercesC_INCLUDE_DIR="${xercesdir}/include" -DXercesC_VERSION="3.2.2" -DZIP_LIBRARY="${basedir}/libzip/bin/libzip" -DZIP_INCLUDE_DIR="${basedir}/libzip/include" -DCMAKE_INSTALL_PREFIX="${installdir}" "${codedir}"

# Build and install
cmake --build . --parallel 8
Expand Down
8 changes: 7 additions & 1 deletion dependencies/xerces.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,15 @@ if (NOT TARGET xercesc)

add_library(xercesc STATIC IMPORTED)

set_target_properties(xercesc PROPERTIES
if (WIN32)
set_target_properties(xercesc PROPERTIES
IMPORTED_LOCATION ${local_xerces_dir}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}xerces-c${CMAKE_SHARED_LIBRARY_SUFFIX}${CMAKE_STATIC_LIBRARY_SUFFIX}
INTERFACE_INCLUDE_DIRECTORIES ${local_xerces_dir}/include)
else()
set_target_properties(xercesc PROPERTIES
IMPORTED_LOCATION ${local_xerces_dir}/lib/${CMAKE_STATIC_LIBRARY_PREFIX}xerces-c${CMAKE_SHARED_LIBRARY_SUFFIX}
INTERFACE_INCLUDE_DIRECTORIES ${local_xerces_dir}/include)
endif()

else()
message(STATUS "Looking for xerces in system")
Expand Down
7 changes: 5 additions & 2 deletions hopsandcp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ target_include_directories(hopsandcp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../dependencies/xerces/include>
$<INSTALL_INTERFACE:include>)

target_link_libraries(hopsandcp hopsancore ${CMAKE_CURRENT_LIST_DIR}/../dependencies/libzip/lib/libzip.dll.a -lws2_32)
#target_link_libraries(hopsandcp hopsancore libzip -lws2_32)
if(WIN32)
target_link_libraries(hopsandcp hopsancore libzip -lws2_32)
else()
target_link_libraries(hopsandcp hopsancore libzip)
endif()

target_compile_definitions(hopsandcp PUBLIC LOGGING=ON)

0 comments on commit b1ecd0a

Please sign in to comment.