Skip to content

Switch to cmake part1 #2251

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

peterNordin
Copy link
Member

This is part one of switch over to CMake, has been in progress for more than three years.
After adding DCP additional work is needed to be able to build release, but i will make a part2

This PR enables me to build all of Hopsan on Linux GCC, Windows MinGW and Windows MSVC 2019.
Including with DCP. But I do not know if it actually works in all these cases. Hopsan at least starts.

Deb build has been migrated to CMake. But flatpak/snap and Windows builds remain.

@peterNordin peterNordin requested a review from robbr48 December 10, 2024 22:58
Copy link
Contributor

@robbr48 robbr48 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems to work except for the DCPLib. It no is no longer compiled and linked since it is header-only. See separate comments in hopsandcp/CMakeLists.txt.

The conflict is just because I fixed the same typo, so it is very easy to fix.

project(hopsandcp)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_DEBUG_POSTFIX _d)
if(WIN32)
set(CMAKE_SHARED_LIBRARY_PREFIX "")
endif()

set(CMAKE_AUTOMOC ON)
include(${CMAKE_CURRENT_LIST_DIR}/../dependencies/dcplib.cmake)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not include this, since DCPLib is header-only and does no longer require linking.


# include(${CMAKE_CURRENT_LIST_DIR}/../dependencies/xerces.cmake)
# include(${CMAKE_CURRENT_LIST_DIR}/../dependencies/libzip.cmake)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need to include libzip.cmake, however, because we must link to libzip directly below.

$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../dependencies/libzip/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../dependencies/asio-code/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../dependencies/xerces/include>
# $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../dependencies/dcplib-code/include/bluetooth>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These include directories are needed, because we need to link to the headers in DCPLib, libzip, Asio and Xerces. But perhaps they should can be in dcplib.cmake if we remove all stuff with linking to the library.

target_link_libraries(hopsandcp hopsancore libzip -lws2_32)
else()
target_link_libraries(hopsandcp hopsancore libzip)
target_link_libraries(hopsandcp hopsancore DCPLib::Master DCPLib::Slave DCPLib::Zip DCPLib::Ethernet)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove: DCPLib::Master, DCPLib::Slave and DCPLib::Zip
Add: libzip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants