Hi, nice video, I found it very helpful to understand some concepts, and some lines of cmake. Although I got some questions, if you don't mind. Basically, when I built the project it throws me an error saying it was not able to find my headers, so in the cmake of my project I added an include_libreries with the path to those headers, when I reran the build command again It throws me an error saying that it didn't identify the namespace that are in the hpp files, something like this "error: ‘MyNamespace::secondNamespace’ has not been declared MyNamespace::secondNamespace::Myfunction" and highlights the second Namespace, to be honest I don't know what could be causing this error could you help me to understand? by the way I'm working with ubuntu and the library has several headers and their own cpp file. thank you again for the video
This is the best cmake tutorial I ever seen on youtube, Thanks man. I have a one question, I currently working on project that uses "glfw3" as an external library, After precompiling It, when I use "find_package(glfw3 REQUIRED)". it does find that library but when I trying link with it.... it gives me a linker error... I'm doing something like this "target_link_libraries( PRIVATE glfw3)", I don't know what is going on, when I change "glfw3" to "glfw" it works, Is it something to do with library it self, or Is it me doing something wrong.....but my qustion is how can find the package name is, when i'm trying to use find_package function... and the other thing is "namespace" can you explain it little bit....
Hey thanks for the kind words. I just cmake-installed glfw on my system, and I'll give you a tip of something I tend to do. When I'm not sure what the targets/namespace setup is like for the library I wish to link to, I go to the "lib\cmake\" folder and I look for the Targets file, the same file I showed how to generate in this video here. In this case, when I poke around in "lib\cmake\glfw3", the targets file seems to export a "glfw" target, meaning, you should probably be linking to that, rather than glfw3, as there is no target defined with the name "glfw3". The package name you're looking for, and the target name you link to DO NOT have to be the same, they are very different things. You can have a package named "foo", so you'd find_package(foo, but foo might export a bunch of libraries called "bar1", "bar2", "bar3", and it's namespace might be "foo". So when you're linking you might end up doing target_link_libraries(myapp foo:bar1 foo::bar3... etc). Hope this makes sense and helps, let me know if you have any other questions.
Nice Video, you are accually the first guy on youtube who explained it. But I have a question: 20:40 - When I use this command, it says that the source directory does not appear to contain CMakeLists.txt - And indeed, there is no file like this in the whole file tree after using cmake --install. What should I do? I have to use Qt so its a bit different I quess
Hey, there should be no CMakeLists.txt in the tree AFTER doing a --install. You are installing the library and the CMakeLists.txt file is the instructions on how to build/install. After installing, you would have the other scripts that I outline in the video which other projects would use to find all your headers and libs. What I'm showing at 20:40 is how one would pass the CMAKE_PREFIX_PATH variable to CMake if they weren't using Visual Studio/IDE and wanted to actually find and link with our library. This part of the video was a test project showing that we had set things up correctly and can actually find and link with our library. If you have gotten to that part, was able to build and install your library, and the files in installed directory match what I showed earlier in the video, congratulations, you did things correctly :)
The entire video is based in Windows. What are you having trouble with? There is no standard usr/lib equivalent, check the video again, I go over how to install a package and how to then find it on Windows.
This is god sent stuff.
Hi, nice video, I found it very helpful to understand some concepts, and some lines of cmake. Although I got some questions, if you don't mind. Basically, when I built the project it throws me an error saying it was not able to find my headers, so in the cmake of my project I added an include_libreries with the path to those headers, when I reran the build command again It throws me an error saying that it didn't identify the namespace that are in the hpp files, something like this "error: ‘MyNamespace::secondNamespace’ has not been declared
MyNamespace::secondNamespace::Myfunction" and highlights the second Namespace, to be honest I don't know what could be causing this error could you help me to understand? by the way I'm working with ubuntu and the library has several headers and their own cpp file. thank you again for the video
This is the best cmake tutorial I ever seen on youtube, Thanks man. I have a one question, I currently working on project that uses "glfw3" as an external library, After precompiling It, when I use "find_package(glfw3 REQUIRED)". it does find that library but when I trying link with it.... it gives me a linker error... I'm doing something like this "target_link_libraries( PRIVATE glfw3)", I don't know what is going on, when I change "glfw3" to "glfw" it works, Is it something to do with library it self, or Is it me doing something wrong.....but my qustion is how can find the package name is, when i'm trying to use find_package function... and the other thing is "namespace" can you explain it little bit....
Hey thanks for the kind words. I just cmake-installed glfw on my system, and I'll give you a tip of something I tend to do. When I'm not sure what the targets/namespace setup is like for the library I wish to link to, I go to the "lib\cmake\" folder and I look for the Targets file, the same file I showed how to generate in this video here. In this case, when I poke around in "lib\cmake\glfw3", the targets file seems to export a "glfw" target, meaning, you should probably be linking to that, rather than glfw3, as there is no target defined with the name "glfw3". The package name you're looking for, and the target name you link to DO NOT have to be the same, they are very different things. You can have a package named "foo", so you'd find_package(foo, but foo might export a bunch of libraries called "bar1", "bar2", "bar3", and it's namespace might be "foo". So when you're linking you might end up doing target_link_libraries(myapp foo:bar1 foo::bar3... etc). Hope this makes sense and helps, let me know if you have any other questions.
Nice Video, you are accually the first guy on youtube who explained it. But I have a question: 20:40 - When I use this command, it says that the source directory does not appear to contain CMakeLists.txt - And indeed, there is no file like this in the whole file tree after using cmake --install. What should I do? I have to use Qt so its a bit different I quess
Hey, there should be no CMakeLists.txt in the tree AFTER doing a --install. You are installing the library and the CMakeLists.txt file is the instructions on how to build/install. After installing, you would have the other scripts that I outline in the video which other projects would use to find all your headers and libs. What I'm showing at 20:40 is how one would pass the CMAKE_PREFIX_PATH variable to CMake if they weren't using Visual Studio/IDE and wanted to actually find and link with our library. This part of the video was a test project showing that we had set things up correctly and can actually find and link with our library. If you have gotten to that part, was able to build and install your library, and the files in installed directory match what I showed earlier in the video, congratulations, you did things correctly :)
What happens to all that on Windows? Is there a Windows equivalent to the linux usr/lib system?
The entire video is based in Windows. What are you having trouble with? There is no standard usr/lib equivalent, check the video again, I go over how to install a package and how to then find it on Windows.
Why even make a video when there's no github link to example project?
Here you go: github.com/constref/cmake-examples/tree/master/cmake-library
@@constref1983 The github link does not seem to be valid.
@@constref1983 That L is not there. Can you please check above again? Thanks