Does this support CMake find_package?

Issue #23 new
Former user created an issue

I'm new to CMake, and am trying to setup CMake for towave in order to link statically with this library (instead of Ubuntu's bundled gme with poor ym2612 emulation). Does this library support find_package?

https://www.youtube.com/watch?v=eC9-iRN2b04 ?

https://stackoverflow.com/questions/22450776/generate-find-cmake-automatically-and-install-it-for-importing ?

Comments (3)

  1. Former user Account Deleted reporter

    OS: Ubuntu 18.04.

    Ended up importing the library using add_subdirectory(game-music-emu) which worked.

    Configuring static linking was difficult for me to find how to work. After much suffering, I found that SET(BUILD_SHARED_LIBS OFF CACHE BOOL "Build shared GME library") worked.

    However, static linking ended up triggering thousands of linker errors, since -static-libubsan wasn't passed to GCC. To fix this issue, I partially modernized CMakeLists:

    • Assign all CMAKE_CXX_FLAGS to cxx_flags instead
    • Call set_target_properties with cxx_flags on each project in the dir (uses BUILDSYSTEM_TARGETS which requires CMake 3.7)
    • Call target_link_libraries(gme ${cxx_flags}) on GME only. See Github diff.
      • Note: I'm not sure whether I should pass all cxx_flags into target_link_libraries, or only pass -static-libubsan.

    Now, target_link_libraries(towave PRIVATE gme) automatically inherits -static-libubsan.

    https://github.com/jimbo1qaz/towave-j/commits/master/game-music-emu I think I should squash the 2 commits before sending a PR here.

  2. Michael Pyne repo owner

    I added the CMake support before I realized that there was a difference between CMake config mode and module mode for FindPackage.

    Although I'm mainly a C++ dev myself, the pkg-config interface is currently the only supported export interface (and that's in the gme/CMakeLists.txt, not the toplevel). That's mostly just due to lack of time, I'd be happy to add the proper CMake bits.

  3. Log in to comment