CMAKE - include directories with special character - makefile

I am currently changing the build system of my project to CMake.
In my CmakeLists.txt i need to add the following directory to my include path :
RSA/PKCS#1v15
To do so i tried the following :
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/RSA/PKCS#1v15)
This fails because of the # character being the cmake commenting symbol.
How can i bypass this behavior ?

Related

Clion: Use a Makefile with a non standard name

Can I configure a CLion project to use a Makefile that is not named literally: Makefile?
I have an older project I'd like to build, but the makefile is called Makfile.osx_sdl2.
I'd like to somehow tell CLion to use that name. Note that, the project also has a Makefile which is somehow used by Makfile.osx_sdl2, so renaming or symlinking won't work.

Compile & Run CLion Project from Terminal

I am trying to create generally-accessible compile & run instructions for my CLion project, but can't find the exact terminal command it uses to execute the program (it's makefile, I would assume). From the project directory in the terminal, how would I do this?
The directory looks like this:
I will add a little bit to #Stanley F.'s excellent answer.
FROM the root of the CLion project, this is what works for me. I generally run with a debug profile. The same can be reproduced for release.
When cmake loads its project, it runs
cmake -Bcmake-debug-build -H. ${CMakeOptions}
where CMakeOptions is stored in CLion at
CLion->settings->Build,Execution, Deployment->CMake->[profile]->CMake Options
My general cmake build option is
-DCMAKE_BUILD_TYPE=debug -DSYTEM_ARCH=Linux-gcc5.3.0-x86_645 -CMAKE_CXX_STANDARD=14
[Note the lower-case d for 'debug'. If I do not use this, my system will not work. I wish that CLion did not default to 'Debug']
So, to reproduce what CLion creates upon project reload, I run
rm -rf cmake-debug-build
cmake -Bcmake-debug-build -H. -DCMAKE_BUILD_TYPE=debug -DSYTEM_ARCH=Linux-gcc5.3.0-x86_645 -CMAKE_CXX_STANDARD=14
Then, to build the project, I run
cmake --build cmake-build-debug --target all
Please note that when I run the first cmake command (from CLion or the command line), cmake pulls in lots of libraries from other "precedent" projects as part of the processing of my CMakeLists.txt file. If anything in one of those precedent projects changes, I will not pull them in anew, unless I physically delete the entire cmake-build-debug/ directory. None of CLion's reset tool menu items from my experience will delete that file.
If I am running these commands from the CLion menus, then I have to physically delete the cmake-build-debug/ directory as well (if I have a change in one of the external libraries that I want to pull in).
CLion currently only supports CMake projects. So you have to invoke the CMake executable with the appropriate parameters for your project.
At first, you can delete the cmake-build-debug folder, since this is auto-generated by CLion, which itself invokes CMake. It only contains temporary files.
So your build environment basically contains the 3DTable.c, 3DTable.h and CMakeLists.txt files. At least this is what I get from the screenshot.
To build the project from command line, first navigate to the source directory. Then invoke CMake:
cd <source path of Project_1>
cmake -Bbuild -H.
cmake --build build --target all
Notes:
build is the directory, where CMake will generate temporary files and the build artifacts.
The -H. option tells CMake, where the CMakeLists.txt file is located, which in this case is the current working directory.
The library / executable for your project will be located within the build directory
CLion can tell you, you don't need to hunt.
CMake command line
Select tools\cmake\reload cmake project.
The command line is shown in the CMake window.
Build command line
Select build\build project.
The command line is shown in the messages window.
Example
Mine look like this:
"C:\Program Files\JetBrains\CLion 2021.2.2\bin\cmake\win\bin\cmake.exe" -DCMAKE_BUILD_TYPE=Debug "-DCMAKE_MAKE_PROGRAM=C:/Program Files/JetBrains/CLion 2021.2.2/bin/ninja/win/ninja.exe" -G Ninja -S C:\some_application -B C:\some_application\cmake-build-debug
...
"C:\Program Files\JetBrains\CLion 2021.2.2\bin\cmake\win\bin\cmake.exe" --build C:\some_application\cmake-build-debug --target all -j 9
Reminder
If using Visual Studio you still to specify which environment you are using. Typically this involves using the VS command prompt or executing one of the premade scripts to set up the environment variables. See here.

How to invoke cmake from within sublime text?

I'm using:
sublime text 3
cmake
make on Mac and mingw-make on windows
So far I'm able to compile and run hello world using cmake and make. I'd like to be able to compile, link and run from within sublime text. By default, I didn't find a build system which allows me to do this.
Also, I understand that sublime text is just an editor but it also provides the notion of a build system where one can plugin your own.
If I run:
cmake .. -G "Sublime Text 2 - MinGW Makefiles"
It generates sublime text project file. When I open this project file in sublime, it populates build system with options from the generated make file (using cmake). It builds the executable but none of the build options allows me to run it.
Can someone help me understand how can I make the sublime run the project executable ?
Please let me know if I need to add more details here.
My directory structure is like this:
root
include
linkedlist.h
src
linkedlist.cpp
CMakeLists.txt
main.cpp
My CMakeLists.txt :
cmake_minimum_required(VERSION 2.8.9)
project(dataStructures)
#Bring the headers, into the project
include_directories(include)
#Can manually add the sources using the set command as follows:
set(MAINEXEC main.cpp)
#However, the file(GLOB...) allows for wildcard additions:
file(GLOB SOURCES "src/*.cpp")
add_executable(testDS ${SOURCES} ${MAINEXEC})

CMake: add_custom_command with output in build config related directory

I've a custom command with some output file.
However there is some issue I have under VisualStudio: the location of generated file is the same for Release and Debug which is not what I want.
I'd like to be able to generate this file in subdir "Relase" or "Debug" as CMake does for all binary files when run with VisualStudio generator.
How can I achieve that?
Use the CMake variable CMAKE_CFG_INTDIR in your custom command, as demonstrated in the documentation.

Adding an additional include directory for VS10

I'm having some trouble figuring out how to add another directory for a single project. On a regular C/C++ project I'm allowed the option of navigating to the directory, but here I have to enter the directory myself, but this is a CUDA c/C++ project. My question is how would I add lets just say: C:\Users\USERNAME\Documents\Visual Studio 2010\Projects\CUDA Programs\common as an include directory.
You should just be able to paste the path into the include directories list. You can separate paths with a semicolon.
c:\foo\baa;c:\program files\blah\blah;c:\whatever
In earlier versions of the build rules, the include directory did not seem to be added correctly if it ended in a backslash, or if it was wrapped in quotes, so try and avoid either of those.
Does this answer you question VS10 "Additional Include Directories" Point to VS9 Includes

Resources