On 10/21/2011 06:49 PM, pellegrini wrote: > Hi all, > > after digging and googling some hours I did a first step in the right > direction. > > I had to add the command: > > enable_language(rc) > set(cmake_rc_compiler_arg1 -cif8) > > The resource compiler I (must) use is the one provided by winteracter > Fortran library. > > This led me to a serie of problems related to the use of this compiler: > - it does not accept any output flag so that the output resource > object is always created "in-source" in the rc file directory. > - on Linux, it produces a .o object file instead of a .res file > > Looking at the CMakeRCInformation.cmake I see that by construction CMake > will use the following compile command: > "<CMAKE_RC_COMPILER> <FLAGS> <DEFINES> /fo<OBJECT> <SOURCE>" > with a resource object file with a .res extension.
You might rewrite this rule variable, e.g. in order to drop /fo<OBJECT>, but this wouldn't resolve your issues, AFAICS. > On a Linux machine, this produces a wrong build command line with the > path for the output object file being "/foCMakeFiles/...". This problem > was raised sometime ago in the mantis bug tracker but unfortunatley the > patch proposed apply for mingw using windres but not for Linux. > > Is there a fix for this ? > > If no, is there a way to inform the linker that: > - my resource object file is located "in-source" You might create symlinks to the resource files - or copy them - so that the winteracter RC generates its output files within the build tree; note that the source tree may be read-only. This could even be done on the fly with an adapted version of ADD_EXECUTABLE/LIBRARY(). > - the extension is not .res but .o You might use a RULE_LAUNCH_COMPILE property in conjunction with a shell script which recognizes RC command lines, moves the .o to a .res in the correct directory and drops the undesired /fo switch. The attached CMakeLists.txt and rc.sh files outline these approaches; check them out with meaningful ${CMAKE_SOURCE_DIR}/{abs,srcdir}.rc and ${CMAKE_BINARY_DIR}/bindir.rc. However, they are untested as I currently haven't any RC at hand; moreover, they're restricted to Makefiles and won't work on Windows. Regards, Michael > pellegrini a écrit : >> Hi all, >> >> I use CMake 2.8.5 on Linux and Windows machine to build a Fortran >> project. >> >> On Windows, no problem, the build and the resulting GUI are OK. On >> Linux, the build seems to >> be OK but the resulting GUI gives an empty screen. Discussing with >> Michael a few days ago made >> me think that it could be related to the use of an inappropriated >> motif library. >> >> However, looking in more details I see with a make VERBOSE=1 that my >> rc file is not built >> (I do not see the line "Building RC object ..."). even if it is >> declared as one of my sources files. >> >> Is there some extra commands to specify to make cmake recognize and >> compile a rc file ? >> >> thanks >> >> Eric
CMAKE_MINIMUM_REQUIRED(VERSION 2.8 FATAL_ERROR) PROJECT(RC C RC) SET(CMAKE_VERBOSE_MAKEFILE ON) FILE(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/rc) FUNCTION(ADD_EXECUTABLE TARGET) UNSET(ARGS) FOREACH(i IN LISTS ARGN) IF(i MATCHES "\\.rc$") IF(IS_ABSOLUTE "${i}") GET_FILENAME_COMPONENT(p "${i}" PATH) FILE(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/rc${p}") EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink "${i}" "${CMAKE_BINARY_DIR}/rc${i}") LIST(APPEND ARGS "${CMAKE_BINARY_DIR}/rc${i}") ELSEIF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${i}") GET_FILENAME_COMPONENT(p "${CMAKE_CURRENT_SOURCE_DIR}/${i}" PATH) FILE(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/rc${p}") EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/${i}" "${CMAKE_BINARY_DIR}/rc${CMAKE_CURRENT_SOURCE_DIR}/${i}") LIST(APPEND ARGS "${CMAKE_BINARY_DIR}/rc${CMAKE_CURRENT_SOURCE_DIR}/${i}") ELSE() GET_FILENAME_COMPONENT(p "${CMAKE_CURRENT_BINARY_DIR}/${i}" PATH) FILE(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/rc${p}") EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_BINARY_DIR}/${i}" "${CMAKE_BINARY_DIR}/rc${CMAKE_CURRENT_BINARY_DIR}/${i}") LIST(APPEND ARGS "${CMAKE_BINARY_DIR}/rc${CMAKE_CURRENT_BINARY_DIR}/${i}") ENDIF() ELSE() LIST(APPEND ARGS "${i}") ENDIF() ENDFOREACH() _ADD_EXECUTABLE(${TARGET} ${ARGS}) ENDFUNCTION() SET_PROPERTY(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "bash ${CMAKE_SOURCE_DIR}/rc.sh <CMAKE_RC_COMPILER> <SOURCE> <OBJECT>") FILE(WRITE ${CMAKE_BINARY_DIR}/main.c "int main(void){return 0;}\n") FILE(WRITE ${CMAKE_BINARY_DIR}/bindir.rc "") # <-- Something meaningful. ADD_EXECUTABLE(main main.c srcdir.rc bindir.rc "${CMAKE_SOURCE_DIR}/abs.rc")
rc.sh
Description: Bourne shell script
-- 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