[cmake-developers] Making Config.cmake files easier to write
Alexander Neundorf
neundorf at kde.org
Thu Feb 16 18:40:48 EST 2012
On Thursday 16 February 2012, Brad King wrote:
> On 2/16/2012 1:24 PM, Alexander Neundorf wrote:
> > Actually I expected I would prefer this over the fixed names, but now
> > that I've done it and look at what Config.cmake.in file I have to write,
> > I think I liked the previous version with the fixed names
> > (CONFIG_HELPER) better. I think it was easier to do, a simple scheme.
>
> I think the fixed names are better/simpler too. I'm not fond of
> "CONFIG_HELPER" specifically. The information stored in them is
> about the *package* that the file is configuring, which is why
> I originally proposed the prefix "PACKAGE_". The INCLUDE_INSTALL_DIR
> is where the *package* goes, not where the config helper is/goes.
I pushed a branch MakingConfigFilesEasier_ConfigureMacro to stage.
It has documentation and a test.
An example Config.cmake.in file is attached.
I can still change names etc. tomorrow.
The macro is in CMakePackageHelpers.cmake.
Alex
-------------- next part --------------
# set the version of myself
set(BAR_VERSION_MAJOR @BAR_VERSION_MAJOR@)
set(BAR_VERSION_MINOR @BAR_VERSION_MINOR@)
set(BAR_VERSION_PATCH @BAR_VERSION_PATCH@)
set(BAR_VERSION ${BAR_VERSION_MAJOR}.${BAR_VERSION_MINOR}.${BAR_VERSION_PATCH} )
@PACKAGE_HELPER_INIT@
set_and_check(BAR_INCLUDE_DIR "@PACKAGE_HELPER_INCLUDE_INSTALL_DIR@")
set_and_check(BAR_BIN_DIR "@PACKAGE_HELPER_BIN_INSTALL_DIR@")
set(BAR_DATA_DIR "@PACKAGE_HELPER_DATA_INSTALL_DIR@")
set(BAR_BAR_DIR "@PACKAGE_HELPER_BAR_INSTALL_DIR@")
set(BAR_FOO_DIR "@PACKAGE_HELPER_FOO_INSTALL_DIR@")
# what is my include directory
set(BAR_INCLUDES "${BAR_INCLUDE_DIR}")
# import the exported targets
include(${CMAKE_CURRENT_LIST_DIR}/BarTargets.cmake)
# set the expected library variable
set(BAR_LIBRARIES bar )
More information about the cmake-developers
mailing list