开发者

CMake: How to generate different shared library names depending on build type

开发者 https://www.devze.com 2022-12-11 22:02 出处:网络
This is my first time using CMake and I\'m trying to build QJSon, a JSON parser for Qt 4.x. What I want basically is to build different output library names depending on the build configuration. I\'m

This is my first time using CMake and I'm trying to build QJSon, a JSON parser for Qt 4.x. What I want basically is to build different output library names depending on the build configuration. I'm using ${CMAKE_BUILD_TYPE} macro to generate different targets (qjson.lib/qjson.dll and qjsond.lib/qjsond.dll). Seems that the VS 2008 solution always builds with the qjson name (no qjsond on debug builds).

My horrible section of Makefile directives is as follows:

       IF("${CMAKE_BUILD_TYPE}" MATCHES "^Rel.*")
         add_library ( qjson SHARED ${qjson_SRCS} ${qjson_MOC_SRCS})
         target_link_libraries( qjson ${QT_LIBRARIES})

         set_target_properties( qjson PROPERTIES
                              VERSION ${QJSON_LIB_MAJOR_VERSION}.
    ${QJSON_LIB_MINOR_VERSION}.${QJSON_LIB_PATCH_VERSION}
                              SOVERSION ${QJSON_LIB_MAJOR_VERSION}
                              DEFINE_SYMBOL QJSON_MAKEDLL
                              ) 

        INSTALL(TARGETS qjson
           LIBRARY DESTINATION ${LIB_INSTALL_DIR}
           RUNTIME DESTINATION bin
           ARCHIVE DESTINATION  ${LIB_INSTALL_DIR}
        )
        ENDIF("${CMAKE_BUILD_TYPE}" MATCHES "^Rel.*")

        I开发者_如何转开发F("${CMAKE_BUILD_TYPE}" MATCHES "^Deb.*")
         add_library ( qjsond SHARED ${qjson_SRCS} ${qjson_MOC_SRCS})
         target_link_libraries( qjsond ${QT_LIBRARIES})

         set_target_properties( qjsond PROPERTIES
                              VERSION ${QJSON_LIB_MAJOR_VERSION}.
${QJSON_LIB_MINOR_VERSION}.
${QJSON_LIB_PATCH_VERSION}
                              SOVERSION ${QJSON_LIB_MAJOR_VERSION}
                              DEFINE_SYMBOL QJSON_MAKEDLL
                              ) 

        INSTALL(TARGETS qjsond
           LIBRARY DESTINATION ${LIB_INSTALL_DIR}
           RUNTIME DESTINATION bin
           ARCHIVE DESTINATION  ${LIB_INSTALL_DIR}
        )
        ENDIF("${CMAKE_BUILD_TYPE}" MATCHES "^Deb.*")

Any ideas? Sure there's a simpler configuration. Thank you.


http://www.cmake.org/cmake/help/cmake-2-8-docs.html#prop_tgt:OUTPUT_NAME_CONFIG

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号