hi,

I need to compile a lot of files generated by some program. I want to generate 
unix-makefiles. the problem is, that linking command generated by cmake is much 
to large (input line too long error). It's is not possible to split this files 
to more libs (even if it would be, I would need about 15 libs). If I generate 
nmake-makefiles, somthing about 2 libs would be enough. 2 libs would be ok, but 
I need unix-makefiles. I can't change directory structure. I thought it would 
be ok if I create object's for all cpp file and then link it (then I can put 
*.o to linker and line is short). But I don't know how can I run command that 
compile all cpp files with all flags, includes and defines. I tried to overcome 
this by creating custom command like:
get_directory_property(DEFINITIONS COMPILE_DEFINITIONS)
get_directory_property(INC_DIRS INCLUDE_DIRECTORIES)
 
FOREACH(INC_DIR ${INC_DIRS})
SET (IDIRS ${IDIRS} -I${INC_DIR})
ENDFOREACH(INC_DIR) 

FOREACH(MFILE ${MED_FILES})
        GET_FILENAME_COMPONENT(_file_we ${MFILE} NAME_WE)
        SET(_out "${_file_we}.o")

        ADD_CUSTOM_COMMAND(
        OUTPUT ${_out}
        COMMAND ${CMAKE_CXX_COMPILER} -c -W:c++:.c ${CMAKE_CXX_FLAGS} 
${DEFINITIONS} ${IDIRS} -o ${_out} ${MFILE}
        ARGS 
        DEPENDS ${MFILE}
        )
        SET(_outputs ${_outputs} ${_out})
ENDFOREACH(MFILE)

add_custom_target(RUOAM  
        DEPENDS ${_outputs}
)
And this is nearly working. One problem is, that there are "\" chars in flags 
and it couse problems. I tried to remove it whith:

STRING(REPLACE '\\' " " FLAGS ${CMAKE_CXX_FLAGS})

but it didn't work. (why?)
The best solution for me would be to run CMAKE_XXX_COMPILE_OBJECT for each cpp 
file, but how can I do this?
my compile object command:
set(CMAKE_CXX_COMPILE_OBJECT "<CMAKE_CXX_COMPILER> -c -W:c++:.c <DEFINES> 
<FLAGS> -o <OBJECT> <SOURCE>")

Br,
Marek

_______________________________________________
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

Reply via email to