countly-sdk-cpp icon indicating copy to clipboard operation
countly-sdk-cpp copied to clipboard

Using -DCMAKE_INSTALL_PREFIX with build produces flat include folder & does not include DLL

Open AndrewAtAvenza opened this issue 2 years ago • 3 comments
trafficstars

If you use -DCMAKE_INSTALL_PREFIX=[some folder] when generating the build files, and then use --target install, you get a badly formed output folder.

The DLL is the easiest one to fix.

install(TARGETS countly ARCHIVE DESTINATION lib PUBLIC_HEADER DESTINATION include/countly)

Should be

install(TARGETS countly ARCHIVE DESTINATION lib PUBLIC_HEADER DESTINATION include/countly RUNTIME DESTINATION bin)

This way, there will be a bin folder containing the countly.dll.

There are a few errors with the include setup. First, countly.hpp needs to be removed from COUNTLY_PUBLIC_HEADERS. While we're at it, add countly_configuration.hpp, which is missing!

Next, add this additional install step at the end of the file:

install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/countly.hpp DESTINATION include)

This will separately install countly.hpp in the root include folder in the install directory, creating the expected setup.

AndrewAtAvenza avatar Jan 04 '23 17:01 AndrewAtAvenza

I can share my version of the CMakeLists.txt if that helps. I'm not say you should necessarily adopt it, but it might provide an idea of where things could use some shoring up. I also tightened up the sqlite pathing so it actually uses the results of find_package(sqlite), which allows someone like me to override using the bundled sqlite in favour of the one we're using elsewhere in our product.

AndrewAtAvenza avatar Jan 10 '23 00:01 AndrewAtAvenza

Hi, would love to see your CMakeList for sure. We want to look into any options to make things sturdier.

turtledreams avatar May 19 '23 11:05 turtledreams

Sure, here's what I'm using currently. I can't remember if I've made any other changes, but obviously feel free to use or ignore whatever you want.

CMakeLists.txt

AndrewAtAvenza avatar May 19 '23 13:05 AndrewAtAvenza