[CMake] Please critique my "hello world" CMakeLists.txt and Config.cmake
Chris Stankevitz
chrisstankevitz at gmail.com
Sat Feb 23 23:37:25 EST 2013
Hello,
Would you please critique my CMakeLists.txt and helloConfig.cmake.in
files? I am particularly interested in comments that will help me fix
these problems:
- In helloConfig.cmake.in, I assume static libraries will be built
(".a"). I imaging a better approach would make no assumptions about
this.
- In helloConfig.cmake.in, I assume ${PREFIX} will expand to the
installed prefix, but it does not.
- I type the same expression many times:
"hello-${hello_VERSION_MAJOR}.${hello_VERSION_MINOR}". I imagine the
better approach would derive this expression from some built-in cmake
variables or from a variable I create.
- INSTALL is looking for helloConfig.cmake in the source directory but
it is in the build directory.
- Any other comments you have
Thank you!
Chris
-------------- next part --------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(hello)
set (hello_VERSION_MAJOR 1)
set (hello_VERSION_MINOR 1)
ENABLE_TESTING()
ADD_LIBRARY(hello hello.cpp)
CONFIGURE_FILE(helloConfig.cmake.in helloConfig.cmake)
INSTALL(
TARGETS
hello
DESTINATION
lib/hello-${hello_VERSION_MAJOR}.${hello_VERSION_MINOR}
)
INSTALL(
FILES
helloConfig.cmake
DESTINATION
lib/hello-${hello_VERSION_MAJOR}.${hello_VERSION_MINOR}
)
INSTALL(
FILES
hello.h
DESTINATION
include/hello-${hello_VERSION_MAJOR}.${hello_VERSION_MINOR}
)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hello.cpp
Type: text/x-c++src
Size: 77 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130223/96641666/attachment.cpp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: hello.h
Type: text/x-chdr
Size: 16 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130223/96641666/attachment.h>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: helloConfig.cmake.in
Type: application/octet-stream
Size: 202 bytes
Desc: not available
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130223/96641666/attachment.obj>
More information about the CMake
mailing list