Hi,
today I have been working with cmake in order to translate a project based on eclipse. I faced a problem and really don’t know if the founded solution is good or not. So, if you have a minute, tell me what you think about…
Problem: the project contains c-language sources and files written in assembler.
The first version of the cmake project obtained was incorrect because the include paths and options, for both kind of files, were the same.
Some errors were present on assembler compilation.
So this is the solution I found:
- create a library with a add_library(CSources STATIC ${SOURCE});
- append includes to the lib with target_include_directories(CSources …file1.c … filen.c);
- set compiler flags with set_target_properties(CSources PROPERTIES COMPILE_DEFINITIONS ${PRJ_DEFINES});
- final target add_executable(${PROJECT_NAME} file_assembly.s $<TARGET_OBJECTS:CSources> );
It works but… I’m quite sure that for the purists I made mistakes…
Personally I dislike to pass defines with a variable PRJ_DEFINES instead to use ADD_DEFINITIONS but if I use it these will be also part of the assembler compilation.
Suggestion are welcome…
Bye