unexpected location for CMakeCache, CMakeFiles and build results
I have a project with the following layout, provided a CMake file in addition to project definitions for MSVC and Xcode (each also in dedicated directories):
SynchroTr
|- lib1Src
|- lib2Src
|- testApp1.c
|- testApp2.cpp
|- CMake
|- CMakeLists.txt
|- build
The CMakeLists.txt file contains
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(SynchroTr)
include(FindPkgConfig)
include(CheckFunctionExists)
include(FeatureSummary)
include_directories(${CMAKE_CURRENT_LIST_DIR}/..)
link_directories(${CMAKE_CURRENT_LIST_DIR} ${CMAKE_BINARY_DIR} ${SPARSEHASH_LIBRARY_DIRS})
add_library(lib1 STATIC ${CMAKE_CURRENT_LIST_DIR}/../lib1Src/lib1.cpp)
add_library(lib2 STATIC ${CMAKE_CURRENT_LIST_DIR}/../lib2Src/lib2.cpp)
add_executable(testApp1 ${CMAKE_CURRENT_LIST_DIR}/../testApp1.c)
target_link_libraries(testApp1 lib1)
set_target_properties(testApp1 PROPERTIES LINKER_LANGUAGE CXX)
add_executable(testApp2 ${CMAKE_CURRENT_LIST_DIR}/../testApp2.cpp)
target_link_libraries(testApp2 lib1 lib2)
My experience with CMake is that
(cd build ; cmake ../CMakeLists.txt) or (cd build ; cmake ../source/CMakeLists.txt)
puts all stuff for building into build
(including CMakeCache.txt). However, when from the source directory I do
(cd CMake/build ; cmake ../CMakeLists.txt)
the directory that is set up for building is not CMake/build, but CMake itself.
I observe this with CMake 3.6.2; I am pretty sure that it used to work as expected with an earlier version.