wgois / OIS

Official OIS repository. Object oriented Input System
https://wgois.github.io/OIS/
zlib License
254 stars 86 forks source link

Building as static lib for VS 2015 gives a CMake error #56

Closed dagophil closed 4 years ago

dagophil commented 4 years ago

Hello,

Bug description: I am trying to build OIS on Windows 7 using the generator "Visual Studio 14 2015". Everything works fine if I leave all CMake Options on their default value. However, when I set OIS_BUILD_SHARED_LIBS to false, CMake fails with the following message:

CMake Error:
  Error evaluating generator expression:

    $<TARGET_PDB_FILE:OIS>

  TARGET_PDB_FILE is allowed only for targets with linker created artifacts.

Steps to reproduce:

git clone https://github.com/wgois/OIS
mkdir build
cd build
cmake -g "Visual Studio 14 2015" -DOIS_BUILD_SHARED_LIBS=0 ..\OIS

Expected behavior: No CMake error.

Platform:

Additional context: I think the error comes from the following lines in CMakeLists.txt:

if(MSVC)
  install(FILES $<TARGET_PDB_FILE:OIS> DESTINATION bin OPTIONAL)
endif(MSVC)

According to the CMake documentation and this CMake issue, the TARGET_PDB_FILE is for linker PDB files, however, static libraries need compiler PDB files. I think it does not make sense to deploy those, so changing above if(MSVC) to the following may be a solution:

if(MSVC AND BUILD_SHARED_LIBS)
  install(FILES $<TARGET_PDB_FILE:OIS> DESTINATION bin OPTIONAL)
endif(MSVC AND BUILD_SHARED_LIBS)

Do you think this is a valid solution? If so, should I add a pull request for the fix?

Ybalrid commented 4 years ago

That's probably valid. It is useful to install PDB files if you want to debug code from inside the library, but if this mitigate your problem, do not hesitate to pull request that change! 😁

Ybalrid commented 4 years ago

closing, see changes in #58