Reputation: 11
I'm new to cmake, and I'm only using Visual studio 19 Community. I have a problem with running the program. The Program is unable to find the correct path/library. Here's the command, I ran;
cd path/to/examples
mkdir build
cd build
cmake -G"Visual Studio 16 2019" -DLEAP_ROOT="C:\Users\User\Desktop\LeapDeveloperKit_3.2.1+45911_win\LeapSDK" ..
Then it returns the error:
CMake Error at CMakeLists.txt:6 (message):
Run CMake in a separate build directory to avoid source code contamination.
-- Configuring incomplete, errors occurred!
See also "C:/Users/User/Desktop/Windows Win64/Examples/CMakeFiles/CMakeOutput.log".
I'm workin wth Windows10 and use prompt. How do I solve it? Here my CmakeLists.txt :
cmake_minimum_required(VERSION 3.3)
project(UltrahapticsExamples)
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR "Run CMake in a separate build directory to avoid source code contamination.")
endif ()
# For FindLeap.cmake
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${CMAKE_MODULE_PATH}")
find_package(Ultrahaptics REQUIRED)
find_package(Leap)
if (LEAP_FOUND)
include_directories(${LEAP_INCLUDE_DIR})
else ()
message(WARNING "Could not find Leap SDK")
endif ()
set(ULTRAHAPTICS_CSHARP_DIR "" CACHE PATH "Ultrahaptics CSharp libraries folder")
if (NOT ULTRAHAPTICS_CSHARP_DIR STREQUAL "" AND EXISTS "${ULTRAHAPTICS_CSHARP_DIR}")
find_file(ULTRAHAPTICS_CSHARP_RUNTIME
NAMES libUltrahapticsCSharp.dylib libUltrahapticsCSharp.so UltrahapticsCSharp.dll
PATHS "${ULTRAHAPTICS_CSHARP_DIR}")
find_file(ULTRAHAPTICS_CSHARP_40 UltrahapticsCSharp.NET40.dll "${ULTRAHAPTICS_CSHARP_DIR}")
if (ULTRAHAPTICS_CSHARP_RUNTIME AND ULTRAHAPTICS_CSHARP_40)
set(ULTRAHAPTICS_CSHARP_FOUND TRUE)
endif()
endif()
add_subdirectory(cpp)
if (ULTRAHAPTICS_CSHARP_FOUND)
add_subdirectory(csharp)
endif()
message(STATUS " ========== Examples Configuration Summary =========\n")
if (LEAP_FOUND)
message(STATUS " Leap: Enabled")
else ()
message(STATUS " Leap: Not Found")
endif ()
message(STATUS "")
Upvotes: 1
Views: 14254
Reputation: 65928
After the project has been configured (at least, partially) as in-source, it is impossible to perform out-of-source builds:
Even if you call cmake
from the other directory, it will behave "as if" called from the source directory.
For make out-of-source build accessible again, you need to cleanup build files in the source directory, namely CMakeCache.txt
file and CMakeFiles
directory.
Upvotes: 1
Reputation: 9331
The error is telling you that your build directory is same as the directory that contains the source. You need to change this to enable out of source build. This will keep your compiled files separate from your source code.
if (CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR)
message(FATAL_ERROR "Run CMake in a separate build directory to avoid source code contamination.")
endif ()
This line checks whether your build and source directories are same, and if they, it gives a fatal error and stops the build.
Here's how to fix it:
C:/Users/User/Desktop/Windows Win64/Examples
mkdir build
// create build directorycd build
// go into this directoryAfter this step the console should show that you are in directory: C:/Users/User/Desktop/Windows Win64/Examples/build
cmake -G"Visual Studio 16 2019" -DLEAP_ROOT="C:\Users\User\Desktop\LeapDeveloperKit_3.2.1+45911_win\LeapSDK" ..
Upvotes: 1