ruslo / cgold Goto Github PK
View Code? Open in Web Editor NEW:whale2: The Hitchhiker’s Guide to the CMake
Home Page: https://cgold.readthedocs.io
License: BSD 2-Clause "Simplified" License
:whale2: The Hitchhiker’s Guide to the CMake
Home Page: https://cgold.readthedocs.io
License: BSD 2-Clause "Simplified" License
fix is needed
Is this in the guide or can it be addressed?
Would be nice to have information on how to use static checks within CMake for projects.
https://blog.kitware.com/static-checks-with-cmake-cdash-iwyu-clang-tidy-lwyu-cpplint-and-cppcheck/
In Return Value, it recommends to set a variable to the parent scope to return a value from function.
But I am wondering if it is possible to return a value via argument of function. It is more commonly seen in CMake for example: ProcessorCount(N), N is a output argument of function.
Is the function argument in CMake passed by reference?
Not working for Android:
Migrated from: https://github.com/ruslo/hunter/issues/359#issuecomment-240917420:
lldb [ for OSX mostly, I guess] would require a . lldbinit
file with contents along the lines of:
settings set target.source-map <old-build-directory>/Build <root-id>/Install
in its project directory [ Xcode needs the plugin https://github.com/alloy/lldb-is-it-not for this to work ]. Information from stackoverflow
I've read many cmake guide or tutorial, but many of them are old-fashioned.
I find what i need in your guide. And i wanna to share this to my Chinese friends.
Is this fine to translate it
Migrated from https://github.com/ruslo/hunter/issues/359#issuecomment-240917420:
gdb would require a .gdbinit file in the debugging directory with:
set substitute-path <old-build-directory>/Build <root-id>/Install
Source: https://sourceware.org/gdb/onlinedocs/gdb/Source-Path.html
OpenCV example: https://github.com/opencv/opencv/blob/bf4c5bef7fa254e996f31d3e3d7f81ce63716c13/cmake/OpenCVModule.cmake#L827-L836
CMake variables:
The example in cmake-sources/with-external-module-good
doesn't work because the path to mymodule.cmake
isn't fully specified (CMAKE Error: include could not find load file: mymodule).
How should the include
statement look correctly?
Add the line list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/../external")
before?
The only way to set variable to parent of the parent scope.
It would be fantastic to be able to download a current version as a epub.
AFAIU, it's something in readthedocs.io project settings.
Thank you.
In https://cgold.readthedocs.io/en/latest/tutorials/out-of-source.html (and on other pages), the -H. and -B flags are used.
According to http://stackoverflow.com/a/31092052, this is undocumented because it shouldn't be used. The answer links to https://cmake.org/pipermail/cmake-developers/2016-June/028843.html, it says
These are undocumented because they are internal options that
are not meant for public use.
So I guess the flags shouldn't be used in the tutorial.
Woud it be possible to add some shortlist of usefull variables/functions.
Perhaps something like this:
https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/Useful-Variables
cmake_minimum_required(VERSION 3.2)
project(foo)
add_library(foo foo.cpp)
target_compile_definitions(foo PUBLIC FOO_FEATURE)
add_library(baz_1 baz_1.cpp)
target_link_libraries(baz_1 PUBLIC foo) # Case 1
add_library(baz_2 baz_2.cpp)
target_link_libraries(baz_2 PRIVATE foo) # Case 2
add_executable(boo_1 boo_1.cpp)
target_link_libraries(boo_1 PRIVATE baz_1)
add_executable(boo_2 boo_2.cpp)
target_link_libraries(boo_2 PRIVATE baz_2)
/usr/bin/c++ -DFOO_FEATURE -o foo.cpp.o -c foo.cpp
/usr/bin/c++ -DFOO_FEATURE -o baz_1.cpp.o -c baz_1.cpp
/usr/bin/c++ -DFOO_FEATURE -o boo_1.cpp.o -c boo_1.cpp # FOO_FEATURE added, foo headers can be used in boo_1.cpp
/usr/bin/c++ boo_1.cpp.o -o boo_1 libbaz_1.a libfoo.a # libfoo.a added, linking is static, we may need symbols
/usr/bin/c++ -DFOO_FEATURE -o baz_2.cpp.o -c baz_2.cpp
/usr/bin/c++ -o boo_2.cpp.o -c boo_2.cpp # FOO_FEATURE is missing, can't use foo headers in boo_2.cpp
/usr/bin/c++ boo_2.cpp.o -o boo_2 libbaz_2.a libfoo.a # libfoo.a added even if PRIVATE used
Always use @ONLY
form.
# CMakeLists.txt
set(A "0")
configure_file(foo.cmake.in foo.cmake)
# foo.cmake.in
set(A "1")
message("A = ${A}") # A from CMakeLists.txt will be used!
# foo.cmake
message("A = ")
Your tutorial is brilliant, and I want to contribute a Chinese translation. Is there any guidance to follow?
Hi Ruslan,
Could you add at some point information about CMAKE_MODULE_LINKER_FLAGS?
I read the docs, but they are not clear to me as to what is meant by modules in this context.
Thanks
In docs/rejected/object-libraries.rst, the affirmation that "library can't be used on the right hand side of target_link_libraries command" is wrong since CMake 3.12.
In this file:
CGold/docs/tutorials/libraries/symbols/tools.rst
The link duplicates:
/examples/library-examples/library-symbols/Boo.cpp
It seems to me, Foo.cpp must be in the second case.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.