-
Notifications
You must be signed in to change notification settings - Fork 44
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
base: master
Are you sure you want to change the base?
Switch to cmake part1 #2251
Conversation
To prevent re-downloading after cleaning code during test builds
Keep the dir to avoid fetching all code every time
Removes warning spam on newer CMake versions
Comment validation tests for now, script does not work
Hopefully it has tar installed in the system
There was a problem hiding this 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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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> |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
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.