[CMake] Please critique my "hello world" CMakeLists.txt and Config.cmake

J Decker d3ck0r at gmail.com
Sun Feb 24 05:38:05 EST 2013


On Sun, Feb 24, 2013 at 2:23 AM, Ansis Māliņš <ansis.malins at gmail.com>wrote:

> # You don't need the .in file.
>
> 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)
>
> # This works just the same. Unless I'm missing something.
> SET(hello_INCLUDE_DIRS
>
> ${CMAKE_INSTALL_PREFIX}/include/hello-${hello_VERSION_MAJOR}.${hello_VERSION_MINOR})
> SET(hello_LIBRARIES
>
> ${CMAKE_INSTALL_PREFIX}/lib/hello-${hello_VERSION_MAJOR}.${hello_VERSION_MINOR}/libhello.a)
>

s/lib/${CMAKE_STATIC_LIBRARY_PREFIX}/
s/.a/${CMAKE_STATIC_LIBRARY_SUFFIX}/

also available ${CMAKE_EXECUTABLE_SUFFIX}  would be blank in your case, but
not always.

${CMAKE_SHARED_LIBRARY_PREFX}
${CMAKE_SHARED_LIBRARY_SUFFX}

PREFIX will be blank for windows platforms and SUFFIX appropriate .lib or
.dll (.a, .so )

>
> 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})
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20130224/67cba382/attachment-0001.htm>


More information about the CMake mailing list