This is what I have, when I started generation:
iMac:IXCSoftswitch alex$ /usr/bin/cmake -G Xcode .
-- CMAKE_SOURCE_DIR = /Users/alex/Desktop/ixc-v/IXCSoftswitch, CMAKE_BINARY_DIR = /Users/alex/Desktop/ixc-v/IXCSoftswitch
CMake Error at CMakeLists.txt:25 (MESSAGE):
Binary and source directory cannot be the same
-- Configuring incomplete, errors occurred!
How can I fix it? I'm new to CMake, samples appreciated.
CMake is used to produce out-of-source builds.
The idea here is that you don't mix the files created during compilation with the original source files. In practice, you usually run CMake from a new, empty build directory and give the path to the source directory as an argument.
cd IXCSoftswitch
mkdir build
cd build
cmake -G Xcode ..
All of the files generated by CMake (which could be a lot) will now go into the build
subdirectory, while your source directory stays clean of build artifacts.
The concept of out-of-source builds may seem strange at first, but it is actually a very convenient way of working once you get used to it.
From the root of your project directory.
cmake -G Xcode -H. -B_build
This is similar to the answer above. However, you are manually managing the out of source build. -B sets your target build directory (I happen to prefer _build). I tried looking up -H to double check, but couldn't find it. If memory serves, it specifies where your CMakeLists.txt lives.
I keep this command in a .sh/.bat file (depending). This way, I can keep my scripts that build my project in the root where a new person can easily find them.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With