From 63de4115dce610a737550a95db6efb7ec67ca907 Mon Sep 17 00:00:00 2001 From: f3nix Date: Sun, 13 Apr 2008 19:07:32 +0000 Subject: [PATCH] CMake: * Add mingw_resource_compiler macro (Win32). * Fix windres wxWidgets include paths (Win32). --- CMakeLists.txt | 3 +++ CMakeModules/MinGWResourceCompiler.cmake | 27 ++++++++++++++++++++++++ cvpcb/CMakeLists.txt | 8 ++----- eeschema/CMakeLists.txt | 8 ++----- gerbview/CMakeLists.txt | 8 ++----- kicad/CMakeLists.txt | 8 ++----- pcbnew/CMakeLists.txt | 8 ++----- 7 files changed, 40 insertions(+), 30 deletions(-) create mode 100644 CMakeModules/MinGWResourceCompiler.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ea63a2c57..582683b51f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -75,6 +75,9 @@ check_find_package_result(wxWidgets_FOUND "wxWidgets") # Include wxWidgets macros. include(${wxWidgets_USE_FILE}) +# Include MinGW resource compiler. +include(MinGWResourceCompiler) + # Include paths. include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/include diff --git a/CMakeModules/MinGWResourceCompiler.cmake b/CMakeModules/MinGWResourceCompiler.cmake new file mode 100644 index 0000000000..e56db68286 --- /dev/null +++ b/CMakeModules/MinGWResourceCompiler.cmake @@ -0,0 +1,27 @@ +# resource compilation for mingw (http://www.cmake.org/Bug/view.php?id=4068) + +macro(dbg_msg _MSG) +# message(STATUS "${CMAKE_CURRENT_LIST_FILE}(${CMAKE_CURRENT_LIST_LINE}): ${_MSG}") +endmacro(dbg_msg) + +macro(mingw_resource_compiler _NAME) + set(_IN "${CMAKE_CURRENT_SOURCE_DIR}/${_NAME}.rc") + dbg_msg("_IN: ${_IN}") + + set(_OUT "${CMAKE_CURRENT_BINARY_DIR}/${_NAME}_rc.o") + dbg_msg("_OUT: ${_OUT}") + + set(_WINDRES_INCLUDE_DIRS -I${CMAKE_CURRENT_SOURCE_DIR}) + foreach(wx_include_dir ${wxWidgets_INCLUDE_DIRS}) + set(_WINDRES_INCLUDE_DIRS ${_WINDRES_INCLUDE_DIRS} -I${wx_include_dir}) + endforeach(wx_include_dir ${wxWidgets_INCLUDE_DIRS}) + dbg_msg("_WINDRES_INCLUDE_DIRS: ${_WINDRES_INCLUDE_DIRS}") + + set(_ARGS ${_WINDRES_INCLUDE_DIRS} -i${_IN} -o${_OUT}) + dbg_msg("_ARGS: ${_ARGS}") + + add_custom_command(OUTPUT ${_OUT} + COMMAND windres.exe + ARGS ${_ARGS} + VERBATIM) +endmacro(mingw_resource_compiler) diff --git a/cvpcb/CMakeLists.txt b/cvpcb/CMakeLists.txt index 897beb2b92..e1c211532b 100644 --- a/cvpcb/CMakeLists.txt +++ b/cvpcb/CMakeLists.txt @@ -58,12 +58,8 @@ set(CVPCB_EXTRA_SRCS if(WIN32) if(MINGW) - # resource compilation for mingw (http://www.cmake.org/Bug/view.php?id=4068) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/cvpcb_rc.o - COMMAND windres.exe -I ${CMAKE_CURRENT_SOURCE_DIR} -I ${wxWidgets_ROOT_DIR}/include - -i ${CMAKE_CURRENT_SOURCE_DIR}/cvpcb.rc - -o ${CMAKE_CURRENT_BINARY_DIR}/cvpcb_rc.o) - set(CVPCB_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/cvpcb_rc.o) + mingw_resource_compiler(cvpcb) + set(CVPCB_RESOURCES ${_OUT}) else(MINGW) set(CVPCB_RESOURCES cvpcb.rc) endif(MINGW) diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index 5dde3624d1..b1e5c36e46 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -104,12 +104,8 @@ set(EESCHEMA_EXTRA_SRCS if(WIN32) if(MINGW) - # resource compilation for mingw (http://www.cmake.org/Bug/view.php?id=4068) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/eeschema_rc.o - COMMAND windres.exe -I ${CMAKE_CURRENT_SOURCE_DIR} -I ${wxWidgets_ROOT_DIR}/include - -i ${CMAKE_CURRENT_SOURCE_DIR}/eeschema.rc - -o ${CMAKE_CURRENT_BINARY_DIR}/eeschema_rc.o) - set(EESCHEMA_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/eeschema_rc.o) + mingw_resource_compiler(eeschema) + set(EESCHEMA_RESOURCES ${_OUT}) else(MINGW) set(EESCHEMA_RESOURCES eeschema.rc) endif(MINGW) diff --git a/gerbview/CMakeLists.txt b/gerbview/CMakeLists.txt index 416f5eb7ba..2b8f571f78 100644 --- a/gerbview/CMakeLists.txt +++ b/gerbview/CMakeLists.txt @@ -60,12 +60,8 @@ set(GERBVIEW_EXTRA_SRCS if(WIN32) if(MINGW) - # resource compilation for mingw (http://www.cmake.org/Bug/view.php?id=4068) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/gerbview_rc.o - COMMAND windres.exe -I ${CMAKE_CURRENT_SOURCE_DIR} -I ${wxWidgets_ROOT_DIR}/include - -i ${CMAKE_CURRENT_SOURCE_DIR}/gerbview.rc - -o ${CMAKE_CURRENT_BINARY_DIR}/gerbview_rc.o) - set(GERBVIEW_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/gerbview_rc.o) + mingw_resource_compiler(gerbview) + set(GERBVIEW_RESOURCES ${_OUT}) else(MINGW) set(GERBVIEW_RESOURCES gerbview.rc) endif(MINGW) diff --git a/kicad/CMakeLists.txt b/kicad/CMakeLists.txt index 186608d58e..b215e8235e 100644 --- a/kicad/CMakeLists.txt +++ b/kicad/CMakeLists.txt @@ -15,12 +15,8 @@ set(KICAD_SRCS if(WIN32) if(MINGW) - # resource compilation for mingw (http://www.cmake.org/Bug/view.php?id=4068) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/kicad_rc.o - COMMAND windres.exe -I ${CMAKE_CURRENT_SOURCE_DIR} -I ${wxWidgets_ROOT_DIR}/include - -i ${CMAKE_CURRENT_SOURCE_DIR}/kicad.rc - -o ${CMAKE_CURRENT_BINARY_DIR}/kicad_rc.o) - set(KICAD_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/kicad_rc.o) + mingw_resource_compiler(kicad) + set(KICAD_RESOURCES ${_OUT}) else(MINGW) set(KICAD_RESOURCES kicad.rc) endif(MINGW) diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 602aad044d..349c49a982 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -151,12 +151,8 @@ set(PCBNEW_EXTRA_SRCS if(WIN32) if(MINGW) - # resource compilation for mingw (http://www.cmake.org/Bug/view.php?id=4068) - add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_rc.o - COMMAND windres.exe -I ${CMAKE_CURRENT_SOURCE_DIR} -I ${wxWidgets_ROOT_DIR}/include - -i ${CMAKE_CURRENT_SOURCE_DIR}/pcbnew.rc - -o ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_rc.o) - set(PCBNEW_RESOURCES ${CMAKE_CURRENT_BINARY_DIR}/pcbnew_rc.o) + mingw_resource_compiler(pcbnew) + set(PCBNEW_RESOURCES ${_OUT}) else(MINGW) set(PCBNEW_RESOURCES pcbnew.rc) endif(MINGW)