[CMake] Parameter LANGUAGE in set_source_files_properties

zia at itsib.ru zia at itsib.ru
Mon Jul 7 05:19:18 EDT 2008


>> I have a little problem.
>> I have project's tree and several files with c extension and I want
>> to compile one file by g++ compiler and not c compiler.
>>
>> ./Trunk
>> |
>>  ->>TEST
>>  |
>>  ->>test.c
>>  ->>test1.c
>>  ->>test2.c
>>  ->>CMakeLists.txt
>> |
>>  ->>CMakeLists.txt
>>
>> ---------------------------------------------
>> I make in root CMakeLists.txt
>> PROJECT (TEST C CXX)
>>
>> add_executable(myexe ${COMMON_SRC})
>> ---------------------------------------------
>> and CMakeLists.txt in TEST's folder
>>
>> SET(COMMON_SRC
>> test.c
>> test1.c
>> )
>>
>> SET_SOURCE_FILES_PROPERTIES(
>> test2.c
>> PROPERTIES
>> LANGUAGE CXX
>> )
>>
>> test.c and test1.c files are right compiling by C cmpiler  but test2.c is not compile CXX compiler this file is not build at all.
>> What do I do wrong?

>test2.c is not compiled because it does not appear in either
>ADD_EXECUTABLE
>or
>ADD_LIBRARY

>add it to something to be built and it will be compiled.

>the SET_SOURCE_FILES_PROPERTIES only tells CMake that
>"if" the file needs to be compiled then it should use a C++ compiler.

I added add_executable(myexe ${COMMON_SRC}) in  CMakeLists.txt in TEST's folder
but CMake wrote that "myexe" was defined in root CMakeLists.txt.

but if I change myexe to myexe2 then test2.c build for other project
or all the same for myexe?
-- 
Erk




More information about the CMake mailing list