We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 4195

Summary: Set the BUILD_INTERFACE PUBLIC header directory so users don't have to set it in their CMake code
Product: SDL Reporter: Steve Robinson <ssrobins>
Component: buildAssignee: Sam Lantinga <slouken>
Status: RESOLVED FIXED QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: 2.0.8   
Hardware: x86   
OS: Windows 10   
Attachments: Modified SDL2 CMakeLists.txt file

Description Steve Robinson 2018-06-09 01:16:16 UTC
Created attachment 3260 [details]
Modified SDL2 CMakeLists.txt file

I build my program with CMake and add the SDL2 source subdirectory to build it at the same time.

When I add SDL2 to the target_link_libraries of my program target, I get this error:
cannot open source file "SDL.h"

I can add the SDL2 include directory in my program target include directories, but if I add a PUBLIC target_include_directories directory into the SDL2 CMake code that setting will propagate to any target that uses the library.  I made the following modification to the target_include_directories commands in the SDL2 CMakeLists.txt file:

target_include_directories(SDL2 PUBLIC
  $<BUILD_INTERFACE:${SDL2_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>)
    
target_include_directories(SDL2-static PUBLIC
  $<BUILD_INTERFACE:${SDL2_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>)

The CMakeLists.txt file with these changes and the changes from my other build bugs is attached.

Verified this works on Windows, Linux, Mac, iOS, and Android.
Comment 1 Steve Robinson 2020-04-19 05:39:34 UTC
Fixed in SDL 2.0.12, thanks!