Fixed bug 3862 - Install is broken when adding SDL2 to an existing CMake project
authorSam Lantinga <slouken@libsdl.org>
Fri, 06 Oct 2017 16:42:43 -0700
changeset 115733a026cc340a7
parent 11572 7e0f1498ddb5
child 11574 696d0036f442
Fixed bug 3862 - Install is broken when adding SDL2 to an existing CMake project

Steve Robinson

In my existing CMake project, I use add_subdirectory to add the source for SDL2. This worked fine in 2.0.5, but now in 2.0.6 when I build the INSTALL CMake target, I get this error:

file INSTALL cannot find "D:/path/to/SDL2Config.cmake".
Call Stack (most recent call first):
3rdparty/SDL2/cmake_install.cmake:32 (include)
3rdparty/cmake_install.cmake:36 (include)
cmake_install.cmake:32 (include)

To fix this, I changed line 1770 from this:
${CMAKE_SOURCE_DIR}/SDL2Config.cmake

To this:
${CMAKE_CURRENT_SOURCE_DIR}/SDL2Config.cmake
CMakeLists.txt
     1.1 --- a/CMakeLists.txt	Fri Oct 06 16:17:50 2017 -0700
     1.2 +++ b/CMakeLists.txt	Fri Oct 06 16:42:43 2017 -0700
     1.3 @@ -1767,7 +1767,7 @@
     1.4  )
     1.5  install(
     1.6    FILES
     1.7 -    ${CMAKE_SOURCE_DIR}/SDL2Config.cmake
     1.8 +    ${CMAKE_CURRENT_SOURCE_DIR}/SDL2Config.cmake
     1.9      ${CMAKE_BINARY_DIR}/SDL2ConfigVersion.cmake
    1.10    DESTINATION ${PKG_PREFIX}
    1.11    COMPONENT Devel