View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008953CMakeCMakepublic2009-04-30 12:442016-06-10 14:30
ReporterRob Blake 
Assigned ToBill Hoffman 
PrioritynormalSeverityminorReproducibilityalways
StatusclosedResolutionmoved 
PlatformOSOS Version
Product VersionCMake-2-6 
Target VersionFixed in Version 
Summary0008953: LANGUAGE property ignored when set from parent directory.
DescriptionI used file(GLOB_RECURSE...) to find all *.c files in my project and set their language property to CXX. This was advised to me to get around bug 0008851. When I set the LANGUAGE property on a .c file that lives in a subdirectory, Cmake still thinks the file is a C file. If I call get_property within the subdirectory's makefile, I see LANGUAGE is set to CXX.

I've attached a test case that reproduces this behavior.
Additional InformationMy test case has 3 files:
CMakeLists.txt:
cmake_minimum_required(VERSION 2.6)

PROJECT(BuildCToCXXSubdir)
file(GLOB_RECURSE C_FILES ${CMAKE_CURRENT_SOURCE_DIR} *.c)
set_source_files_properties(${C_FILES} PROPERTIES LANGUAGE CXX)

add_subdirectory(subdir)

subdir/CMakeLists.txt:
add_executable(test main.c)

subdir/main.c
#include <iostream>
using namespace std;

int main() {
  cout << "Hello World!" << endl;
  return 0;
}


When I run cmake and try to compile the above project, I get:
[100%] Building C object subdir/CMakeFiles/test.dir/main.c.o

If I try to access the LANGUAGE property of main.c, I see that it's set to CXX.
If I rewrite the entire project so that it lives in one directory, main.c is built as a CXX file. The bug only seems to appear when you have subdirectories.
TagsNo tags attached.
Attached Filestgz file icon cmake_cpp_test.tgz [^] (543 bytes) 2009-04-30 12:44

 Relationships

  Notes
(0017443)
Bill Hoffman (manager)
2009-09-14 13:00

Source files are not global, but are directory based... You might want to try another approach. Maybe have your own add_exectuable macro or keep your files in variables, and create a macro, set_lang_cxx that would set the source file properties on a list of sources to CXX.
(0041550)
Kitware Robot (administrator)
2016-06-10 14:27

Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.

 Issue History
Date Modified Username Field Change
2009-04-30 12:44 Rob Blake New Issue
2009-04-30 12:44 Rob Blake File Added: cmake_cpp_test.tgz
2009-09-14 13:00 Bill Hoffman Note Added: 0017443
2009-09-14 13:00 Bill Hoffman Status new => assigned
2009-09-14 13:00 Bill Hoffman Assigned To => Bill Hoffman
2016-06-10 14:27 Kitware Robot Note Added: 0041550
2016-06-10 14:27 Kitware Robot Status assigned => resolved
2016-06-10 14:27 Kitware Robot Resolution open => moved
2016-06-10 14:30 Kitware Robot Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team