Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
CMake
CMake
Commits
74b1c9fc
Commit
74b1c9fc
authored
Jun 01, 2020
by
Robert Maynard
Browse files
Explicitly specify language flag when source LANGUAGE property is set
Fixes:
#14516
,
#20716
parent
457170a4
Changes
7
Hide whitespace changes
Inline
Side-by-side
Source/cmExtraSublimeTextGenerator.cxx
View file @
74b1c9fc
...
...
@@ -349,6 +349,13 @@ std::string cmExtraSublimeTextGenerator::ComputeFlagsForObject(
if
(
language
.
empty
())
{
language
=
"C"
;
}
// explicitly add the explicit language flag before any other flag
// this way backwards compatibility with user flags is maintained
if
(
source
->
GetProperty
(
"LANGUAGE"
))
{
lg
->
AppendFeatureOptions
(
flags
,
language
,
"EXPLICIT_LANGUAGE"
);
}
std
::
string
const
&
config
=
lg
->
GetMakefile
()
->
GetSafeDefinition
(
"CMAKE_BUILD_TYPE"
);
...
...
Source/cmGlobalXCodeGenerator.cxx
View file @
74b1c9fc
...
...
@@ -819,6 +819,14 @@ cmXCodeObject* cmGlobalXCodeGenerator::CreateXCodeSourceFile(
default:
break
;
}
// explicitly add the explicit language flag before any other flag
// this way backwards compatibility with user flags is maintained
if
(
sf
->
GetProperty
(
"LANGUAGE"
))
{
this
->
CurrentLocalGenerator
->
AppendFeatureOptions
(
flags
,
lang
,
"EXPLICIT_LANGUAGE"
);
}
const
std
::
string
COMPILE_FLAGS
(
"COMPILE_FLAGS"
);
if
(
cmProp
cflags
=
sf
->
GetProperty
(
COMPILE_FLAGS
))
{
lg
->
AppendFlags
(
flags
,
genexInterpreter
.
Evaluate
(
*
cflags
,
COMPILE_FLAGS
));
...
...
Source/cmMakefileTargetGenerator.cxx
View file @
74b1c9fc
...
...
@@ -532,6 +532,13 @@ void cmMakefileTargetGenerator::WriteObjectRuleFiles(
// Build the set of compiler flags.
std
::
string
flags
;
// explicitly add the explicit language flag before any other flag
// this way backwards compatibility with user flags is maintained
if
(
source
.
GetProperty
(
"LANGUAGE"
))
{
this
->
LocalGenerator
->
AppendFeatureOptions
(
flags
,
lang
,
"EXPLICIT_LANGUAGE"
);
}
// Add language-specific flags.
std
::
string
langFlags
=
cmStrCat
(
"$("
,
lang
,
"_FLAGS"
,
filterArch
,
")"
);
this
->
LocalGenerator
->
AppendFlags
(
flags
,
langFlags
);
...
...
Source/cmNinjaTargetGenerator.cxx
View file @
74b1c9fc
...
...
@@ -188,7 +188,16 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject(
}
}
std
::
string
flags
=
this
->
GetFlags
(
language
,
config
,
filterArch
);
std
::
string
flags
;
// explicitly add the explicit language flag before any other flag
// this way backwards compatibility with user flags is maintained
if
(
source
->
GetProperty
(
"LANGUAGE"
))
{
this
->
LocalGenerator
->
AppendFeatureOptions
(
flags
,
language
,
"EXPLICIT_LANGUAGE"
);
flags
+=
" "
;
}
flags
+=
this
->
GetFlags
(
language
,
config
,
filterArch
);
// Add Fortran format flags.
if
(
language
==
"Fortran"
)
{
...
...
Tests/SetLang/CMakeLists.txt
View file @
74b1c9fc
...
...
@@ -8,3 +8,10 @@ add_executable(SetLang bar.c)
set_source_files_properties
(
foo.c bar.c PROPERTIES LANGUAGE CXX
)
target_link_libraries
(
SetLang foo
)
set_target_properties
(
SetLang PROPERTIES LINKER_LANGUAGE CXX
)
if
((
CMAKE_C_COMPILER_ID MATCHES
"(GNU|Clang|MSVC|Borland|Embarcadero|Intel|TI|XL)"
))
add_library
(
zoom zoom.zzz
)
set_source_files_properties
(
zoom.zzz PROPERTIES LANGUAGE CXX
)
target_link_libraries
(
SetLang zoom
)
target_compile_definitions
(
SetLang PRIVATE WITH_ZOOM
)
endif
()
Tests/SetLang/bar.c
View file @
74b1c9fc
#include
<stdio.h>
int
foo
();
#ifdef WITH_ZOOM
int
zoom
();
#endif
class
A
{
public:
A
()
{
this
->
i
=
foo
();
}
A
()
{
this
->
i
=
foo
();
#ifdef WITH_ZOOM
i
+=
zoom
();
i
-=
zoom
();
#endif
}
int
i
;
};
...
...
Tests/SetLang/zoom.zzz
0 → 100644
View file @
74b1c9fc
int zoom()
{
int r = 10;
r++;
int ret = r + 10;
return ret;
}
Brad King
@brad.king
mentioned in commit
7925279c
·
Jun 11, 2020
mentioned in commit
7925279c
mentioned in commit 7925279c20754113227202848545804cde30a3b6
Toggle commit list
Brad King
@brad.king
mentioned in commit
48aac247
·
Dec 04, 2020
mentioned in commit
48aac247
mentioned in commit 48aac247e922409b4dfe7189521661df4b0583d1
Toggle commit list
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment