Find_Library_Ex for msvc
Hi, msvc needs to distinguish between debug and release libs to avoid crashes (it use a different runtime and therefore some symbols/functions are incompatible). To respect this behaviour, we currently need to add a whole bunch of cmake lines to every FindFoo.cmake. For an example see FindBlitz.cmake To simplify this, I wrote a new macro FIND_LIBRARY_EX() which allows a new keyword 'WIN32_DEBUG_POSTFIX' (similar to cmake's DEBUG_POSTFIX). Due to cmake script limitations it needs to be the second and third argument: FIND_LIBRARY_EX(BLITZ_LIBRARIES WIN32_DEBUG_POSTFIX d qimageblitz PATHS $ENV{QIMAGEBLITZDIR}/lib ${KDE4_LIB_DIR} ${LIB_INSTALL_DIR} ) - on win32, qimageblitz (release lib) and qimageblitzd (debug lib) is searched and added to BLITZ_LIBRARIES - it does not change anything on non-win32 platforms I would like to check in this change tomorrow. Later I want to change all kde libraries to have a debug postfix on win32 and use this macro for those libs too. Any objections? Christian Index: modules/FindBlitz.cmake === --- modules/FindBlitz.cmake (revision 715620) +++ modules/FindBlitz.cmake (working copy) @@ -10,6 +10,8 @@ # Redistribution and use is allowed according to the terms of the BSD license. # For details see the accompanying COPYING-CMAKE-SCRIPTS file. +include(FindLibraryEx) + if (BLITZ_INCLUDES AND BLITZ_LIBRARIES) set(Blitz_FIND_QUIETLY TRUE) endif (BLITZ_INCLUDES AND BLITZ_LIBRARIES) @@ -23,32 +25,15 @@ ${KDE4_INCLUDE_DIR} ${INCLUDE_INSTALL_DIR} ) -if(MSVC) - FIND_LIBRARY(BLITZ_LIBRARIES_DEBUG NAMES qimageblitzd) - FIND_LIBRARY(BLITZ_LIBRARIES_RELEASE NAMES qimageblitz) - if(BLITZ_LIBRARIES_DEBUG AND BLITZ_LIBRARIES_RELEASE) -set(BLITZ_LIBRARIES optimized ${BLITZ_LIBRARIES_RELEASE} -debug ${BLITZ_LIBRARIES_DEBUG}) - else(BLITZ_LIBRARIES_DEBUG AND BLITZ_LIBRARIES_RELEASE) -if(BLITZ_LIBRARIES_DEBUG) - set(BLITZ_LIBRARIES ${BLITZ_LIBRARIES_DEBUG}) -else(BLITZ_LIBRARIES_DEBUG) - if(BLITZ_LIBRARIES_RELEASE) -set(BLITZ_LIBRARIES ${BLITZ_LIBRARIES_RELEASE}) - endif(BLITZ_LIBRARIES_RELEASE) -endif(BLITZ_LIBRARIES_DEBUG) - endif(BLITZ_LIBRARIES_DEBUG AND BLITZ_LIBRARIES_RELEASE) -else(MSVC) - FIND_LIBRARY(BLITZ_LIBRARIES - NAMES - qimageblitz - PATHS - $ENV{QIMAGEBLITZDIR}/lib - ${KDE4_LIB_DIR} - ${LIB_INSTALL_DIR} - ) -endif(MSVC) +FIND_LIBRARY_EX(BLITZ_LIBRARIES + WIN32_DEBUG_POSTFIX d + qimageblitz + PATHS + $ENV{QIMAGEBLITZDIR}/lib + ${KDE4_LIB_DIR} + ${LIB_INSTALL_DIR} +) include(FindPackageHandleStandardArgs) find_package_handle_standard_args(Blitz DEFAULT_MSG Index: modules/FindKDEWIN32.cmake === --- modules/FindKDEWIN32.cmake (revision 715620) +++ modules/FindKDEWIN32.cmake (working copy) @@ -14,6 +14,8 @@ if (WIN32) + include(FindLibraryEx) + if (NOT KDEWIN32_DIR) if(NOT KDEWIN_FOUND) find_package(KDEWIN REQUIRED) @@ -26,50 +28,15 @@ # search for kdewin32 in the default install directory for applications (default of (n)make install) -find_library(KDEWIN32_LIBRARY_DEBUG NAMES kdewin32d +find_library_ex(KDEWIN32_LIBRARY + WIN32_DEBUG_POSTFIX d + NAMES kdewin32 PATHS ${CMAKE_LIBRARY_PATH} ${CMAKE_INSTALL_PREFIX}/lib NO_SYSTEM_ENVIRONMENT_PATH ) -find_library(KDEWIN32_LIBRARY_RELEASE NAMES kdewin32 - PATHS -${CMAKE_LIBRARY_PATH} -${CMAKE_INSTALL_PREFIX}/lib - NO_SYSTEM_ENVIRONMENT_PATH -) - -# msvc makes a difference between debug and release -if(MSVC) - find_library(KDEWIN32_LIBRARY_DEBUG NAMES kdewin32d -PATHS - ${CMAKE_LIBRARY_PATH} - ${CMAKE_INSTALL_PREFIX}/lib -NO_SYSTEM_ENVIRONMENT_PATH - ) - if(MSVC_IDE) -# the ide needs the debug and release version -if( NOT KDEWIN32_LIBRARY_DEBUG OR NOT KDEWIN32_LIBRARY_RELEASE) - message(FATAL_ERROR \nCould NOT find the debug AND release version of the KDEWIN32 library.\nYou need to have both to use MSVC projects.\nPlease build and install both kdelibs/win/ libraries first.\n) -endif( NOT KDEWIN32_LIBRARY_DEBUG OR NOT KDEWIN32_LIBRARY_RELEASE) -SET(KDEWIN32_LIBRARY optimized ${KDEWIN32_LIBRARY_RELEASE} debug ${KDEWIN32_LIBRARY_DEBUG}) - else(MSVC_IDE) -string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_TOLOWER) -if(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) - set(KDEWIN32_LIBRARY ${KDEWIN32_LIBRARY_DEBUG}) -else(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) - set(KDEWIN32_LIBRARY ${KDEWIN32_LIBRARY_RELEASE}) -endif(CMAKE_BUILD_TYPE_TOLOWER MATCHES debug) - endif(MSVC_IDE) -else(MSVC) - if(KDEWIN32_LIBRARY_RELEASE) - set(KDEWIN32_LIBRARY ${KDEWIN32_LIBRARY_RELEASE}) -
kdelibs/kjs/CMakeLists.txt
Howdy, I'm using cmake from cvs and it found a problem in kdelibs/kjs/CMakeLists.txt: Warning: Source file /data/kde/trunk/KDE/kdelibs/build-gcc/kjs/kjs_automoc.cpp is listed multiple times for target kjs. I think this is due to having a library named 'kjs' and a separate app named 'kjs'. The warning goes away if I change set(kjs_SRCS kjs.cpp) kde4_add_executable(kjs NOGUI ${kjs_SRCS}) target_link_libraries(kjs ${KJSLIBNAME}) install(TARGETS kjs DESTINATION ${BIN_INSTALL_DIR}) to set(kjs_SRCS kjs.cpp) kde4_add_executable(kjshell NOGUI ${kjs_SRCS}) target_link_libraries(kjshell ${KJSLIBNAME}) install(TARGETS kjshell DESTINATION ${BIN_INSTALL_DIR}) i.e, rename the app 'kjs' to 'kjshell'. Not sure if there is a better way to fix the warning.. I doubt we want to change the name of the kjs application. Ideas? -Allen ___ Kde-buildsystem mailing list Kde-buildsystem@kde.org https://mail.kde.org/mailman/listinfo/kde-buildsystem
Re: kdelibs/kjs/CMakeLists.txt
On 23.09.07 14:50:47, Allen Winter wrote: I'm using cmake from cvs and it found a problem in kdelibs/kjs/CMakeLists.txt: Warning: Source file /data/kde/trunk/KDE/kdelibs/build-gcc/kjs/kjs_automoc.cpp is listed multiple times for target kjs. I think this is due to having a library named 'kjs' and a separate app named 'kjs'. The warning goes away if I change set(kjs_SRCS kjs.cpp) kde4_add_executable(kjs NOGUI ${kjs_SRCS}) target_link_libraries(kjs ${KJSLIBNAME}) install(TARGETS kjs DESTINATION ${BIN_INSTALL_DIR}) to set(kjs_SRCS kjs.cpp) kde4_add_executable(kjshell NOGUI ${kjs_SRCS}) target_link_libraries(kjshell ${KJSLIBNAME}) install(TARGETS kjshell DESTINATION ${BIN_INSTALL_DIR}) i.e, rename the app 'kjs' to 'kjshell'. Not sure if there is a better way to fix the warning.. I doubt we want to change the name of the kjs application. Dirk recently changed the executable from js to kjs because js conflicts with seamonkey. I'm for changing the application binary to kjshell. Andreas -- Things will be bright in P.M. A cop will shine a light in your face. ___ Kde-buildsystem mailing list Kde-buildsystem@kde.org https://mail.kde.org/mailman/listinfo/kde-buildsystem
Re: kdelibs/kjs/CMakeLists.txt
On 23.09.07 16:58:37, Matt Rogers wrote: On Sunday 23 September 2007 13:50:47 Allen Winter wrote: Howdy, I'm using cmake from cvs and it found a problem in kdelibs/kjs/CMakeLists.txt: Warning: Source file /data/kde/trunk/KDE/kdelibs/build-gcc/kjs/kjs_automoc.cpp is listed multiple times for target kjs. I think this is due to having a library named 'kjs' and a separate app named 'kjs'. The warning goes away if I change set(kjs_SRCS kjs.cpp) kde4_add_executable(kjs NOGUI ${kjs_SRCS}) target_link_libraries(kjs ${KJSLIBNAME}) install(TARGETS kjs DESTINATION ${BIN_INSTALL_DIR}) to set(kjs_SRCS kjs.cpp) kde4_add_executable(kjshell NOGUI ${kjs_SRCS}) target_link_libraries(kjshell ${KJSLIBNAME}) install(TARGETS kjshell DESTINATION ${BIN_INSTALL_DIR}) i.e, rename the app 'kjs' to 'kjshell'. Not sure if there is a better way to fix the warning.. I doubt we want to change the name of the kjs application. kde4_add_executable(kjs_bin kjs.cpp) set_target_properties(kjs_bin PROPERTIES OUTPUT_NAME kjs) the above will work as well and keeps us from renaming the library again. Huh, why should the library need a rename? It would just stay as kjs target name. Allen is only talking about changing the app's target name to kjshell. Andreas -- You work very hard. Don't try to think as well. ___ Kde-buildsystem mailing list Kde-buildsystem@kde.org https://mail.kde.org/mailman/listinfo/kde-buildsystem
Re: kdelibs/kjs/CMakeLists.txt
On Sunday 23 September 2007 17:51:17 Andreas Pakulat wrote: On 23.09.07 16:58:37, Matt Rogers wrote: On Sunday 23 September 2007 13:50:47 Allen Winter wrote: Howdy, I'm using cmake from cvs and it found a problem in kdelibs/kjs/CMakeLists.txt: Warning: Source file /data/kde/trunk/KDE/kdelibs/build-gcc/kjs/kjs_automoc.cpp is listed multiple times for target kjs. I think this is due to having a library named 'kjs' and a separate app named 'kjs'. The warning goes away if I change set(kjs_SRCS kjs.cpp) kde4_add_executable(kjs NOGUI ${kjs_SRCS}) target_link_libraries(kjs ${KJSLIBNAME}) install(TARGETS kjs DESTINATION ${BIN_INSTALL_DIR}) to set(kjs_SRCS kjs.cpp) kde4_add_executable(kjshell NOGUI ${kjs_SRCS}) target_link_libraries(kjshell ${KJSLIBNAME}) install(TARGETS kjshell DESTINATION ${BIN_INSTALL_DIR}) i.e, rename the app 'kjs' to 'kjshell'. Not sure if there is a better way to fix the warning.. I doubt we want to change the name of the kjs application. kde4_add_executable(kjs_bin kjs.cpp) set_target_properties(kjs_bin PROPERTIES OUTPUT_NAME kjs) the above will work as well and keeps us from renaming the library again. Huh, why should the library need a rename? It would just stay as kjs target name. Allen is only talking about changing the app's target name to kjshell. Andreas s/library/binary in my reply ___ Kde-buildsystem mailing list Kde-buildsystem@kde.org https://mail.kde.org/mailman/listinfo/kde-buildsystem