Closed arthurbiancarelli closed 5 years ago
My mistake on the second commit I did not want to push it on this branch. I pushed here instead, and can make an other pull request if you are interested.
The idea behind the second commit is to create an install target and to export CMake configuration files.
When running make install
, you'll have in the installation directory:
├── include
├── cpu.hpp
├── gpu.hpp
├── infoware.hpp
├── system.hpp
└── version.hpp
├── lib
└── libinfowared.a
└── share
└── infoware
├── infowareConfig-debug.cmake
├── infowareConfig.cmake
└── infowareConfigVersion.cmake
_Note: You can configure the installation directory with CMAKE_INSTALL_PREFIX
, otherwise it will be the default GNU directories on UNIX platforms (/usr/include, /usr/lib )_
To choose the headers that will be exported, you'll have to set them as PUBLIC_HEADERS
, hence the variable I added.
The share
folder is useful for external projects built with CMake too using your library. Indeed in another project, to use this library, all you have to do then is find_package(infoware)
and target_link_libraries(${PROJECT_NAME} PRIVATE infoware)
.
CMake is then handling everything else (Include directories, compile definitions, dependencies).
CMake is creating infowareConfig.cmake
that contains the common infos for you project and is creating a config file by build type (infowareConfig-debug.cmake
for instance) for specific rules.
The infowareConfigVersion.cmake is just here to handle the versions, for instance an external project can do find_package(infoware 1.0)
to have a specific version
When I do find_package(infoware)
in my project, CMake will take automatically the corresponding library (debug or release), depending on my project's CMAKE_BUILD_TYPE
.
The debug postfix I added (notice the d at the end libinfowared
) is not mandatory but useful just to know in which mode the library was built (when configured with CMake with CMAKE_BUILD_TYPE
).
hmm this is making a lot of sense.
Please do open that PR, I have a few nit-picks I'd like to ask you, as someone who understands CMake better, about the commit there?
Released in v0.2.0
.
I'm sold on the first commit, but not necessarily on the second one as it is right now – why are we defining the postfixes? what's the purpose of whatever sort of CMake compost's going into
$PREFIX/share/infoware/
?