Skip to content
Snippets Groups Projects
Commit 8a2977ba authored by Cristian Adam's avatar Cristian Adam :speech_balloon: Committed by Brad King
Browse files

OBJCXX: Fix regression for compiling cpp files as objcxx

In commit 8d61294c (PCH: Mark CMake PCH source files as -x
<lang>-header, 2020-09-04, v3.18.3~14^2) we removed the explicit `-x
objective-c++` flag.  This broke cases with custom source extensions.

Restore the explicit `-x objective-c[++]` flag and put it before the
`<FLAGS>` placeholder.  The latter will contain the proper `-x
objective-c[++]-header` value and will override the `-x objective-c[++]`
value set before.

Fixes: #21234
parent 7d4e9a3a
No related branches found
No related tags found
No related merge requests found
......@@ -170,7 +170,7 @@ endif()
# compile an Objective-C file into an object file
if(NOT CMAKE_OBJC_COMPILE_OBJECT)
set(CMAKE_OBJC_COMPILE_OBJECT
"<CMAKE_OBJC_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -x objective-c -o <OBJECT> -c <SOURCE>")
"<CMAKE_OBJC_COMPILER> <DEFINES> <INCLUDES> -x objective-c <FLAGS> -o <OBJECT> -c <SOURCE>")
endif()
if(NOT CMAKE_OBJC_LINK_EXECUTABLE)
......
......@@ -263,7 +263,7 @@ endif()
# compile an Objective-C++ file into an object file
if(NOT CMAKE_OBJCXX_COMPILE_OBJECT)
set(CMAKE_OBJCXX_COMPILE_OBJECT
"<CMAKE_OBJCXX_COMPILER> <DEFINES> <INCLUDES> <FLAGS> -o <OBJECT> -c <SOURCE>")
"<CMAKE_OBJCXX_COMPILER> <DEFINES> <INCLUDES> -x objective-c++ <FLAGS> -o <OBJECT> -c <SOURCE>")
endif()
if(NOT CMAKE_OBJCXX_LINK_EXECUTABLE)
......
......@@ -2,3 +2,4 @@ ADD_TEST_MACRO(ObjCXX.ObjC++ ObjC++)
ADD_TEST_MACRO(ObjCXX.simple-build-test simple-build-test)
ADD_TEST_MACRO(ObjCXX.cxx-file-extension-test cxx-file-extension-test)
ADD_TEST_MACRO(ObjCXX.objcxx-file-extension-test objcxx-file-extension-test)
ADD_TEST_MACRO(ObjCXX.cxx-as-objcxx cxx-as-objcxx)
cmake_minimum_required(VERSION 3.18)
project(cxx-as-objcxx LANGUAGES OBJCXX)
add_executable(cxx-as-objcxx main.cpp)
set_source_files_properties(main.cpp PROPERTIES LANGUAGE OBJCXX)
#import <Foundation/Foundation.h>
int main(int argc, char* argv[])
{
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment