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 3269

Summary: CMake 3.5 could not build SDL source
Product: SDL Reporter: gfan
Component: buildAssignee: Sam Lantinga <slouken>
Status: NEW --- QA Contact: Sam Lantinga <slouken>
Severity: normal    
Priority: P2    
Version: don't know   
Hardware: All   
OS: All   

Description gfan 2016-02-23 22:09:45 UTC
in CMakeLists.txt, we have :

if(${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
  message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the SDL source code and call cmake from there")
endif()

in CMake version 3.5-RCx, CMAKE_BINARY_DIR is internally setting ( looks like  ) to be the same as CMAKE_SOURCE_DIR. So the above comparison will end up with always TRUE, hence could not build.  This happens with all version of CMAKE 3.5 RC.  CMake guys recommended not to manually mess up CMAKE_BINAR_DIR, so they have no plan to make it behaves the same as earlier cmake versions.

With some experiments, looks this could be fixed with

if(${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
  message(FATAL_ERROR "Prevented in-tree built. Please create a build directory outside of the SDL source code and call cmake from there")
endif()

CMAKE_CURRENT_SOURCE_DIR & CMAKE_CURRENT_BINARY_DIR approach works for both cmake 3.5 RC versions and also 3.4, 3.3