[CMake] CMake 3.5-CMAKE_BINARY_DIR is set to ${CMAKE_SOURCE_DIR} when calling add_subdirectory?

Gerry Fan gerry.fan at gmail.com
Sun Feb 21 23:45:27 EST 2016


before calling add_subdirectory, set up 2 variables like:
  set(CMAKE_SOURCE_DIR /Users/test/proj/fplbase)
  set(CMAKE_BINARY_DIR  /Users/test/proj/fplbase/build)
  add_subdirectory(${sdl_dir} “/Users/test/proj/fplbase/obj”)
  
In module ${dl_dir}’s CMakeLists.txt, at the beginning, it has:
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()

Somehow the above error is always triggered, does not matter what I set CMAKE_BINARY_DIR to. when printing out CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR, CMAKE_BINARY_DIR is set to the same path as CMAKE_SOURCE_DIR ( /Users/test/proj/fplbase ) in module ${dl_dir}

this only  happens with CMake 3.5-RCx, not happening with previous make versions ( 3.4, 3.3 ). 

seems this checkin began to have it:
commit c4e1bc6ed24d57ef3136756802aa575642927ff1
Merge: f9cc671 0aef6f2
    Merge branch ‘release


Is this a bug?

thank you

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160221/d1b7417a/attachment.html>


More information about the CMake mailing list