Skip to content

Commit

Permalink
Merge pull request ninja-build#2110 from splinter-build/compile-getop…
Browse files Browse the repository at this point in the history
…t-as-c++

Compile getopt as a C++ file, so that CMake need not look for a C compiler at all
  • Loading branch information
jhasse authored Aug 25, 2022
2 parents b5f521a + 2671855 commit ee98487
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ include(CheckIPOSupported)

option(NINJA_BUILD_BINARY "Build ninja binary" ON)

project(ninja)
project(ninja CXX)

# --- optional link-time optimization
check_ipo_supported(RESULT lto_supported OUTPUT error)
Expand Down Expand Up @@ -128,10 +128,18 @@ if(WIN32)
src/getopt.c
src/minidump-win32.cc
)
# Build getopt.c, which can be compiled as either C or C++, as C++
# so that build environments which lack a C compiler, but have a C++
# compiler may build ninja.
set_source_files_properties(src/getopt.c PROPERTIES LANGUAGE CXX)
else()
target_sources(libninja PRIVATE src/subprocess-posix.cc)
if(CMAKE_SYSTEM_NAME STREQUAL "OS400" OR CMAKE_SYSTEM_NAME STREQUAL "AIX")
target_sources(libninja PRIVATE src/getopt.c)
# Build getopt.c, which can be compiled as either C or C++, as C++
# so that build environments which lack a C compiler, but have a C++
# compiler may build ninja.
set_source_files_properties(src/getopt.c PROPERTIES LANGUAGE CXX)
endif()

# Needed for perfstat_cpu_total
Expand Down

0 comments on commit ee98487

Please sign in to comment.