This question already has answers here:
How to include an additional CMakeLists.txt
(2 answers)
Closed 10 months ago.
I want to create a second file, for example Instructions.txt, and be able to include it's CMake instructions to the main CMakeLists.txt, for example:
// Instructions.txt
set(MY_VARIABLE value)
set(MY_SECOND_VARIABLE 1234)
// CMakeLists.txt
<HERE INCLUDE INSTRUCTIONS.TXT>
// And be able to use those variables, for example
project(MY_VARIABLE)
You usually do that simply by using another cmake.
Contrary to what you might believe, the file extension is different for other file than build files.
Let's call this file instructions.cmake:
set(MY_VARIABLE value)
set(MY_SECOND_VARIABLE 1234)
Then you can include it like this inside your CMakeLists.txt:
include(instructions.cmake)
If the file is in the module path, you can include it like that:
include(instructions)
There are some other filename that are important for CMake though.
For example, any file that start with Find then ends with .cmake like FindXYZ.cmake, the XYZ part is assumed to be a package name and in that case you should use find_package(XYZ REQUIRED).
Related
This question already has answers here:
Is it possible to exclude files from git language statistics?
(2 answers)
Closed 2 months ago.
Solution:
Create .gitattributes in git folder and paste linguist-languate=text after the file path. Example:
/other_libraries/* linguist-language=text
/linguist_ignore.c linguist-language=text
Note: linguist-vendored=false didn't solve the problem. GitHub still detected marked files as C code.
Problem:
My C++/OpenGL project is compiled using glad.c, and stb_imbage.h is included in mail.cpp file. Both located in root folder which contains .git directory. These two files have to be present in order to compile the project, so I want to keep them.
Issue: GitHub indexes these files and adds them to Language statistic. It is undesirable since it is not the files containing my code.
How do I keep certain files tracked by Git but exclude them from Languages?
I've tried looking for solution in GitHub docs about Linguist and Stack Overflow but without success.
I know how to ignore files using .gitignore. But it's not the solution since ignored files just won't be commited.
GitHub uses Linguist library to generate the language stats.
At https://github.com/github/linguist/blob/master/docs/overrides.md you can read about the ways to override the default behavior using a .gitattributes file. It looks like the following section fits your case the most:
Vendored code
Checking code you didn't write, such as JavaScript libraries, into your git repo is a common practice, but this often inflates your project's language stats and may even cause your project to be labeled as another language. By default, Linguist treats all of the paths defined in vendor.yml as vendored and therefore doesn't include them in the language statistics for a repository.
Use the linguist-vendored attribute to vendor or un-vendor paths:
(exmaple follows)
This question already has answers here:
In CMake, how can I find the directory of an included file?
(4 answers)
Closed 4 years ago.
I'm writing a .cmake file that handles a bunch of stuff and needs access to an executable in a fixed relative path to the .cmake file. In this instance, the orgianization looks like this:
CMakeLists.txt
- cmake
- tools.cmake
- bin
- exectuable.exe
The issue is that tools.cmake is included using include and thus, CMAKE_CURRENT_SOURCE_DIR returns the directory of the CMakeLists.txt. The reason I don't want to hardcode the path is that I want to put the tools.cmake and binary in a separate GIT repository and I don't want to force the user to place it in some specific folder.
Only solution I can come up with right now is to supply a function that sets and stores the path to tools.cmake. That's not really elegant.
Answered here: https://stackoverflow.com/a/12854575/2532768
CMAKE_JUCE_TOOLS_PATHdoes not return the correct path within functions or macros in tools.cmake but it results in the correct path outside any function. So one can us
set(PATH_TO_TOOLS_CMAKE ${CMAKE_JUCE_TOOLS_PATH})
to store the path while it can be accessed in a variable and than access PATH_TO_TOOLS_CMAKE in functions and macros
This question already has answers here:
Rename files and directories recursively under ubuntu /bash
(8 answers)
Closed 5 years ago.
I am using this command to replace a word with another in many filenames (batch):
rename 's/oldname/newname/g' **
But it works for the current open folder only. I am not sure how to make it work for that directory and all the sub-directories.
Thanks.
Mike,
Try this: Create new folders, move files, delete old folder. Then, move over directories.
Regards
I just started using VSCode on linux Ubuntu environment and for past one day trying to include some header files from a sub-Directory (the project screen shot is shown below).
I have tired adding the header file path in include path but showing error.(Image below)
I also tired by provided complete path e.g. /home/user/Work/Cpp_Test_Project/OpenFace/FaceAnalyser/include/ still it couldn't find the header file.
Also, If I try to include the header with local path e.g.
#include <OpenFace/LandmarkDetector/LandmarkCoreIncludes.h
then all the internally linked header file doesn't work.
any help will be highly appreciated.
The c_cpp_properties.json file is for configuring IntelliSense. The compiler you are using does not read from this file, so you will need to configure the include path for that separately. From what you have posted, it is unclear how you have set up your build.
This question already has answers here:
How to include package data with setuptools/distutils?
(14 answers)
Closed 6 years ago.
Is it possible to include a csv file as part of python package?
I am creating a package and want some default config files which are imported at runtime.
I know I can store as a list or other structure in a .py file, but this will break the pattern I'm building against.
This can be done in a two-step process, as detailed here.
You need one file in the root of your source, MANIFEST.in which reads:
include path/to/yourfile.csv
and you also need to add include_package_data=True, to the setup() function in setup.py.
Tried and tested.
I guess that you may use a specific module more than an "homemade version" to store configuration.
In your case:
The Python standard library includes the ConfigParser module, which handles ini-style configuration files for you.