fallahn / tmxlite

lightweight C++14 parser for Tiled tmx files
Other
404 stars 69 forks source link

Find tmxlite on Windows #126

Closed LuckeeDev closed 1 year ago

LuckeeDev commented 1 year ago

I'm trying to build a program that uses tmxlite on Windows. I built the library and everything seems to work fine, how can I allow CMake to find it? Here's my directory tree:

...
├── CMakeLists.txt
└── modules
    └── tmxlite
        ├── bin
        │   └── libtmxlite.dll
        ├── include
        │   └── tmxlite
        │       ├── Config.hpp
        │       ├── FreeFuncs.hpp
        │       ├── ImageLayer.hpp
        │       ├── Layer.hpp
        │       ├── LayerGroup.hpp
        │       ├── Map.hpp
        │       ├── Object.hpp
        │       ├── ObjectGroup.hpp
        │       ├── ObjectTypes.hpp
        │       ├── Property.hpp
        │       ├── TileLayer.hpp
        │       ├── Tileset.hpp
        │       ├── Types.hpp
        │       ├── Types.inl
        │       └── detail
        │           ├── Android.hpp
        │           └── Log.hpp
        └── lib
            ├── libtmxlite.dll.a
            └── pkgconfig
                └── tmxlite.pc
...

I'm having troubles with both header files and library files. It can't find neither of them.

fallahn commented 1 year ago

If you've installed the library to a sub-directory of your project, you can add it to your project's cmake file directly:

include_directories(${CMAKE_SOURCE_DIR}/modules/tmxlite/include)
link_directories(${CMAKE_SOURCE_DIR}/modelues/tmxlite/lib)

and then add it to the linker list of your executable

  add_executable(foo ${FOO_SRCS})
  target_link_libraries(foo tmxlite)
LuckeeDev commented 1 year ago

Thank you, that worked! And what should I do if I installed tmxlite to a global folder?

fallahn commented 1 year ago

It's not so straight forward on windows, as there aren't default library paths like on linux/unix. This Stack Overflow answer might help: https://stackoverflow.com/questions/21314893/what-is-the-default-search-path-for-find-package-in-windows-using-cmake

LuckeeDev commented 1 year ago

Thank you!