generate CMakeList.text for OS X - cmake

I'm trying to create a plugin for OBS using C, and compiling it using cmake .. && make see - https://github.com/jp9000/obs-studio/wiki/Install-Instructions#mac-osx
when running cmake .. && make from cmd it gives me an error that cmake: command not found and when I run it from the program it gives me an error - CMake Error: The source directory "/Users/gerwin/Desktop/soOBS" does not appear to contain CMakeList.text specify --help for usage, or press the help button on the cmake GUI
How can I generate a CMakeList.Text to compile my soOBS script to a .so file?

One problem is that cmake is not in your path. So, if you type cmake from your command line it cannot be found. The other problem is that you are not specifying correctly your source directory: you have to specify as source directory the location of the main/root CMakeLists.txt.
So, proceed as follow:
Locate your cmake executable, obtaining your <full path to cmake>
Open a shell
Go to your source directory (location of the main/root of obs-studio CMakeLists.txt)
mkdir build
cd build
<full path to cmake> ..The first argument .. is your source directory, location of the main CMakeLists.txt
make

Related

How to set CMake variable to include directory

When trying to build this library with Cmake from the Developer Command Prompt for VS, I get this error
CMake Error at cmake/FindEigen.cmake:77 (MESSAGE):
Failed to find Eigen - Could not find eigen3 include directory, set
EIGEN_INCLUDE_DIR to path to eigen3 include directory, e.g.
/usr/local/include/eigen3.
I'd like find out what was intended of me here: am I to set EIGEN_INCLUDE_DIR with a command line argument or by editing the make file?
I've tried cmake -D EIGEN_INGLUDE_DIR=C:\Users\a\Downloads\eigen-3.3.7\eigen-3.3.7 . but received the same error.
cmake -D EIGEN_INGLUDE_DIR=C:\Users\a\Downloads\eigen-3.3.7\eigen-3.3.7 . failed without creating any files (cmake .. at least started building) and gave me this error
CMake Error: The source "C:/Users/a/Downloads/RpolyPlusPlus-master/RpolyPlusPlus-master/build/CMakeLists.txt" does not match the source "C:/Users/a/Downloads/RpolyPlusPlus-master/RpolyPlusPlus-master/CMakeLists.txt" used to generate cache. Re-run cmake with a different source directory.
So I just ended up adding this to the .cmake file:
# TODO: Add standard Windows search locations for Eigen.
LIST(APPEND EIGEN_CHECK_INCLUDE_DIRS
/usr/local/include
/usr/local/homebrew/include # Mac OS X
/opt/local/var/macports/software # Mac OS X.
/opt/local/include
/usr/include
C:\\Users\\a\\Downloads\\eigen-3.3.7) <---------------------------------------

Installing no longer existing files

I have a list of various files that I want to install, by executing a resulting INSTALL project. This works, but sometimes files are no longer available, when the install operation is executed. Environment is a build server, where files get moved around -> this causes the build to be faulty.
An easy way to fix this behaviour is in the OPTIONAL parameter of the install command. So my question is: Is there a way to output warnings at runtime, if the install command failed?
Here is my code, to recreate the issue. In the src directory there are files "1.txt" and "2.txt". I build the cmakelists.txt and then delete "2.txt". After that, I execute the INSTALL solution I got.
cmake_minimum_required(VERSION 3.0)
project(documentation)
set(SOURCEDOCUMENTATION "D:/projects/side_master/src/documentation/src")
set(TARGETDOCUMENTATION "D:/projects/side_master/src/documentation/tgt")
file (GLOB files_to_install "${SOURCEDOCUMENTATION}/*")
foreach(file_to_install ${files_to_install})
install(FILES ${file_to_install} DESTINATION ${TARGETDOCUMENTATION} OPTIONAL)
endforeach()
The error (without the OPTIONAL parameter):
-- Install configuration: "Debug"
-- Installing: D:/projects/side_master/src/documentation/tgt/1.txt
CMake Error at cmake_install.cmake:56 (file):
file INSTALL cannot find
"D:/projects/side_master/src/documentation/src/2.txt".
What I want to get is a generated message, like this:
File "D:/projects/side_master/src/documentation/src/2.txt" not found.
You could make use of the install(SCRIPT ...) or install(CODE ...) signatures of the CMake install command, to run custom installation steps specific to your use case. The custom steps here would check for the existence of the files (using CMake's EXISTS logic) to be installed, and print a warning message if the file does not exist. The custom installation command could look something like this:
install(CODE "
if(NOT EXISTS ${file_to_install})
message(WARNING \"File ${file_to_install} not found during installation.\")
endif()
")

Is there a command on CMake to started executable resulted from build?

I'm trying to write generic way to run executable resulted after build using CMake's way.
git clone git#github.com:gargamel/ihatesmurfs.git
cmake -E make_directory build
cmake -Sihatesmurfs -Bbuild
cmake --build build
cmake -E chdir build
Now I want to start executable but on *nix, it's like:
./output
and on Windows:
output.exe
Is there a way to escape this with any possible CMake command?
Expanding on my comment a bit, you can modify the CMakeLists.txt file of the project to include add_custom_command. If your CMake creates an executable named HateSmurfs, you can add the custom command to run the executable after compilation completes:
add_executable(HateSmurfs smurfs.cpp)
# Add this piece of code to run the executable after it is built.
add_custom_command(
TARGET HateSmurfs
POST_BUILD
COMMAND HateSmurfs
)
According to add_custom_command documentation:
COMMAND
If COMMAND specifies an executable target name (created by the add_executable() command) it will automatically be replaced by the location of the executable created at build time.

Why does the CMake command show "The source directory "/home/shubham" does not appear to contain CMakeLists.txt."?

I am installing libfreenect2 on Linux.
I am following the steps given in https://github.com/OpenKinect/libfreenect2.
Command
cmake .. -DCMAKE_INSTALL_PREFIX=$HOME/freenect2"
gives me an error:
"CMake Error: The source directory "/home/shubham" does not appear to contain CMakeLists.txt.
When I searched for "CMakeLists.txt" file, it is in the libfreenect2 folder.

error while working with Makefile project

I am trying to debug my Makefile based project which I have imported in CLion. I created a simple CMake file as below
cmake_minimum_required(VERSION 2.8.4)
project(Project1)
set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "" FORCE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ")
add_custom_target(myProject COMMAND make -j4 DEBUG=1
CLION_EXE_DIR=${PACKAGE_DIR})
CMake tool shows me error: CMake executable not specified. I tried adding add_executable(myProject ${SOURCE_FILES}) with correct source files, but still same error.
Where as on Edit Configurations page, I cannot select any Configuration. The drop down for Configuration is empty. At the bottom I get error Error: Configuration is not specified..
When I try to debug the program, I get a warning message Configuration is still incorrect. Do you want to edit it again? I click on Continue Anyway, which compiles the program as I expect and it generates the correct executable file as well. But it cannot run the executable because of the errors in the Configurations.
I assume "CMake executable" refers to the location of the executable cmake which is called to configure your project. Probably you have to search for a setting in CLion where you can define /usr/bin/cmake or whereever your cmake resides.
This solved the problem for me (Ubuntu):
sudo apt-get install cmake