I am retired and been away from programming for several years. I am writing an application that stores all its info in XML files. I am using vscode and cmake under linux mint for building. It is big enough now that I want to run it through doxygen to see all the relationships.
I'm using leethomason/tinyxml2 from github to read/write/access my XML for the project. (A very nice lightweight XML lib, BTW.) Since it only consistes of a single header and source file I have been just compilling them with my code. But the doxygen docs show all the interelationships within tinyxml which is distracting for my purpose. So it is time to break it out into its on lib.
I can build the tinyxml github clone fine. It generates a libtinyxml2d.so, a cmake_install.cmake and cmake_uninstall.cmake (and all the other stuff) in the build directory. What I cannot figure out how to do is to tell my project cmake file how to include the lib.
The tinyxml2 CMakeLists.txt file says:
# Export cmake script that can be used by downstream project
# via `include()`
export(TARGETS tinyxml2
FILE ${CMAKE_BINARY_DIR}/${TARGETS_EXPORT_NAME}.cmake)
install(TARGETS tinyxml2
EXPORT ${TARGETS_EXPORT_NAME}
RUNTIME
DESTINATION ${CMAKE_INSTALL_BINDIR}
COMPONENT tinyxml2_runtime
LIBRARY
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT tinyxml2_libraries
ARCHIVE
DESTINATION ${CMAKE_INSTALL_LIBDIR}
COMPONENT tinyxml2_libraries)
But I cannot figure out how to use that info to link the lib into my cmake file. I search and read the documentation but that is like reading a foreign language because of all the stuff I've forgotten or never knew. (cmake, linux and vscode are all new worlds for me.)
Can someone give an old guy a few pointers? Where to look for examples that are not rudimentary "how to use cmake", or tutorials for lib installation/access.
Thanks,
Eddie
Well, I succeeded but I feel really dumb for it.
I did some more poking around and found how to use the install file.
I did:
cmake -P cmake_install.cmake
which copied it to the system directory like I wanted then simply added the lib name to the target command in the cmake file.
Turns out that wasn't the problem I was trying to cure.
I forgot to remove the tinyxml cpp ad h files from the directory that doxygen was using.
Well, Duh...
Eddie
Related
I'm currently work with the project that chosen the CMake as the build system.
Nonetheless, I'm not very familiar with CMake. I spent much time on including the third-party library, the result is not very prefer. Could someone provide a way to fix my scenario?
My project tree is given in following section:
|--->top-Level
|--->ThirdLib
|------>Lib1
|---------->DLL
|---------->Include
|---------->LIB
|------>Lib2
|---------->DLL
|---------->Include
|---------->LIB
|--->UseThirdLib
|----->test.h //this file will used third-part lib
it seems u need some basic cmake tutorial?
https://cmake.org/cmake/help/latest/guide/tutorial/Adding%20a%20Library.html
target_include_directories
target_link_libraries
in Top level CmakeLists.txt
include_directories(${PROJECT_SOURCE_DIR}/ThirdLib/Lib1/include)
include_directories(${PROJECT_SOURCE_DIR}/ThirdLib/Lib2/include)
target_link_directories(your_target_name ${PROJECT_SOURCE_DIR}/ThirdLib/Lib1/lib)
target_link_directories(your_target_name ${PROJECT_SOURCE_DIR}/ThirdLib/Lib2/lib)
And all .dll should be placed in the same folder as executable or env:PATH should refer to folder with .dlls
Is there a way to quickly scaffold a basic C++ CMake project using CMake itself? For examples in an empty directory calling cmake new then CMake asks a few questions e.g. project name, lisence and generator. Then CMake generates all the required files and directories, e.g. CMakeLists.txt file, src directory and probably initialize it as Git repository.
I don't know of such features and I don't see a point to add scaffolding into CMake itself. There are free and popular tools specifically for scaffolding purpose, so I suggest you to go to yeoman or slush generators search pages and search for cmake.
You may write a CMake function to create an empty project with a specific layout.
file command helps you to create files and directories.
I have an existing C++ cmake project and I want to use tensorflow in it as a third party library. I searched extensively but all the solutions involve installing tensorflow at the end or copying the files to /usr/local directory.
My problem is I don't want to make any changes to the system directories and everything should happen within my project directory.
So, I compiled libtensorflow_cc.so and libtensorflow_framework.so from tensorflow source code and copied into my project directory. I added below code in my CMake to link these libraries.
find_library(tensorflowlibfwk libtensorflow_framework.so
PATHS ${PROJECT_SOURCE_DIR}/thirdparty/lib)
find_library(tensorflowlibcc libtensorflow_cc.so
PATHS ${PROJECT_SOURCE_DIR}/thirdparty/lib)
target_link_libraries(tensorflowtest ${tensorflowlibfwk} ${tensorflowlibcc})
I have no idea about which headers should I include to use the tensorflow in my project ??
Any kind of help please
I'm developing a lib and now trying to make it usable through cmake find_package keyword.
Using the config mode works fine.
I've put the CPackConfig.cmake generated by cmake inside the installation folder of my lib by naming it log++Config.cmake and it can be found in my project. Fine.
But this method is not satisfying. I need to define my own variables such as lib dependencies needed to link and some custom macros, and didn't found any way to embed this inside the CPackConfig.cmake.
So now I'm trying to use the module mode of find_package. My concern is that I can't find any way to have cmake use my Findlog++.cmake without putting it inside cmake installation folders (which is awfully ugly).
I've found some posts telling to just put this file inside my project root but it's almost as ugly as modifying cmake itself.
Is there a way to have my Findlog++.cmake file somewhere inside my lib folder and have cmake finding it without setting the CMAKE_MODULE_PATH variable?
You seem to be confused between CPack and 'config file packages'. First, understand that they are separate and different. Then read
http://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html#creating-packages
http://www.cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html
to learn about usage requirements and inclusion of macros etc.
i am having problems integrating ITK - Insight Toolkit into another image processing pipeline. ITK itself is a medical image processing toolkit and uses cmake as build system. My image pipeline project uses cmake as well. According to the user manual of ITK it is favorable to use the "UseITK.cmake" file in the build (out of source) directory of ITK. You can do that by adding the following lines the CMakeList.txt of your own project.
# 'SET(ITK_DIR ...)' if 'FIND_PACKAGE(ITK REQUIRED)' fails
FIND_PACKAGE(ITK REQUIRED)
INCLUDE(${ITK_USE_FILE})
My problem is, this approach points to the current installtion of ITK, but i have to integrate itk completly into my project, without dependencies outside my project.
Is there a build option in the cmake build system of itk, which dumps/delivers all the header and lib files into a build directory, so i can place them into my project on my own.
I have a lib and header include structure i do not want to break. I already tried to to manually copy the lib and header files into my project but it didn't work out.
I am new to itk and cmake so this question might sound vague. I hope you guys can help me anyway.
Thanks in advance!
Best regards,
zhengtonic
I don't know if you're still having the problem, but here's an easy way:
Build the ITK project, and then "make install" (or build the INSTALL.vcproj project in VS), and it will write to a directory you pass as CMAKE_INSTALL_PREFIX while configuring your project. This directory will contain /bin, /lib and /include. You can import those into your project directly.
Using CMAKE_INSTALL_PREFIX to point to you base directory is the best solution.
When you issue "make install" all the headers/configurationfiles/libraries will be copied over.
C:/Program Files (x86)/ITK is value of CMAKE_INSTALL_PREFIX for ITK and set automatically.