Skip to content

Commit

Permalink
Fix CMake build
Browse files Browse the repository at this point in the history
  • Loading branch information
robbr48 committed Oct 22, 2024
1 parent d86bf52 commit 61b61fd
Show file tree
Hide file tree
Showing 13 changed files with 68 additions and 89 deletions.
1 change: 0 additions & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ build_script:
- setupFMILibrary.bat
- setupFmi4c.bat
- setupXerces.bat
- setupZlib.bat
- setupLibzip.bat
- setupDCPLib.bat
# - setupHDF5.bat (takes to long to build)
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/ci-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ jobs:
call setupQwt.bat
call setupFmi4c.bat
call setupXerces.bat
call setupZlib.bat
call setupLibzip.bat
call setupDCPLib.bat
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ cmake_policy(SET CMP0079 NEW)
set(HOPSANCORE_INSTALL_DST "HopsanCore")
message(WARNING "Hopsan CMake support is still experimental, but should be working for for GCC / MinGW and limited MSVC build")

set(CMAKE_CXX_FLAGS -Wa,-mbig-obj)

enable_testing()

add_subdirectory(doc)
Expand Down
4 changes: 3 additions & 1 deletion HopsanGUI/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/../helpers.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../dependencies/qwt.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../dependencies/discount.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../dependencies/katex.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../dependencies/xerces.cmake)

set(target_name hopsangui)

Expand All @@ -33,7 +34,8 @@ if(NOT CMAKE_BUILD_TYPE MATCHES Debug)
endif()

target_link_libraries(${target_name} Qt5::Core Qt5::Gui Qt5::Widgets Qt5::Xml Qt5::Svg Qt5::Network Qt5::Test Qt5::PrintSupport
qwt hopsancore hopsangeneratorgui symhop ops hopsandcp libzip)
qwt hopsancore hopsangeneratorgui symhop ops hopsandcp xercesc )

target_link_optional_libraries(${target_name} libhopsanremoteclient hopsanhdf5exporter discount katex)

set_target_properties(${target_name} PROPERTIES INSTALL_RPATH "\$ORIGIN/../lib")
Expand Down
6 changes: 0 additions & 6 deletions dependencies/dependencies.xml
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@
</releasefile>
</dependency>

<dependency name="zlib">
<releasefile sha256="72af66d44fcc14c22013b46b814d5d2514673dda3d115e64b690c1ad636e7b17">
<url>https://github.com/madler/zlib/releases/download/v1.3.1/zlib131.zip</url>
</releasefile>
</dependency>

<dependency name="libzip">
<releasefile sha256="242083351e0a568e6ae69ca05f8eb76ed028807bf39cd8fcb4ea58d409ae0f3f">
<url>https://github.com/nih-at/libzip/archive/v1.7.3.zip</url>
Expand Down
20 changes: 20 additions & 0 deletions dependencies/libzip.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
set(local_libzip_dir ${CMAKE_CURRENT_LIST_DIR}/libzip)
find_library(libzip NAMES libzip PATHS ${local_libzip_dir}/lib)

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)

else()
message(STATUS "Looking for libzip in system")
find_package(libzip CONFIG) # Search in system
if (libzip_FOUND)
message(STATUS "Found libzip")
add_library(libzip INTERFACE)
else()
message(WARNING "Could not find libzip")
endif()
endif()
3 changes: 3 additions & 0 deletions dependencies/setupAll.bat
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ start /wait cmd /c setupZeroMQ.bat
start /wait cmd /c setupKatex.bat
start /wait cmd /c setupTclap.bat
start /wait cmd /c setupHDF5.bat
start /wait cmd /c setupXerces.sh
start /wait cmd /c setupLibzip.sh

1 change: 0 additions & 1 deletion dependencies/setupAll.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@
./setupKatex.sh
./setupTclap.sh
./setupHDF5.sh
./setupAsio.sh
./setupXerces.sh
./setupLibzip.sh
27 changes: 0 additions & 27 deletions dependencies/setupAsio.bat

This file was deleted.

27 changes: 0 additions & 27 deletions dependencies/setupAsio.sh

This file was deleted.

25 changes: 0 additions & 25 deletions dependencies/setupZlib.bat

This file was deleted.

30 changes: 30 additions & 0 deletions dependencies/xerces.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
if (NOT TARGET xercesc)
set(local_xerces_dir ${CMAKE_CURRENT_LIST_DIR}/xerces)
set(CMAKE_FIND_LIBRARY_PREFIXES lib)
find_library(xercesc NAMES xerces-c PATHS ${local_xerces_dir}/lib)

#set(CMAKE_FIND_DEBUG_MODE TRUE)
#find_package(xercesc CONFIG PATHS ${local_xerces_dir} NO_DEFAULT_PATH REQUIRED) # Search for local version
#set(CMAKE_FIND_DEBUG_MODE FALSE)

if (xercesc)
message(STATUS "Found local xerces")
#add_library(xercesc INTERFACE)

add_library(xercesc STATIC IMPORTED)

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()
message(STATUS "Looking for xerces in system")
find_package(xercesc CONFIG) # Search in system
if (xercesc_FOUND)
message(STATUS " Found xerces")
add_library(xercesc INTERFACE)
else()
message(WARNING "Could not find xerces")
endif()
endif()
endif()
10 changes: 10 additions & 0 deletions hopsandcp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ endif()

set(CMAKE_AUTOMOC ON)

# include(${CMAKE_CURRENT_LIST_DIR}/../dependencies/xerces.cmake)
# include(${CMAKE_CURRENT_LIST_DIR}/../dependencies/libzip.cmake)
# include(${CMAKE_CURRENT_LIST_DIR}/../dependencies/zlib.cmake)
include(${CMAKE_CURRENT_LIST_DIR}/../dependencies/libzip.cmake)
#include(${CMAKE_CURRENT_LIST_DIR}/../dependencies/zlib.cmake)

# Find source code
file(GLOB_RECURSE srcfiles src/*.cpp)
file(GLOB_RECURSE headerfiles include/*.h include/*.hpp)
Expand All @@ -31,4 +37,8 @@ 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)

target_compile_definitions(hopsandcp PUBLIC LOGGING=ON)

0 comments on commit 61b61fd

Please sign in to comment.