Skip to content

Commit

Permalink
CMake: checks C++ compiler before setting project languages
Browse files Browse the repository at this point in the history
I could not find a better solution. It seems like the languages must be set before almost everything.
  • Loading branch information
nicmorais committed Mar 30, 2024
1 parent efa5cd9 commit ec85273
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
cmake_minimum_required(VERSION 3.4)

project(LibVNCServer VERSION 0.9.14 LANGUAGES C)
set(PROJECT_LANGUAGES C)

if(NOT ${CMAKE_CXX_COMPILER} STREQUAL "")
set(CMAKE_CXX_STANDARD 17)
set(PROJECT_LANGUAGES C CXX)
endif(NOT ${CMAKE_CXX_COMPILER} STREQUAL "")

project(LibVNCServer VERSION 0.9.14 LANGUAGES ${PROJECT_LANGUAGES})
include(CheckFunctionExists)
include(CheckSymbolExists)
include(CheckIncludeFile)
Expand All @@ -25,9 +32,6 @@ set(TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test)
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(${CMAKE_CXX_COMPILER} NOT STREQUAL "")
set(CMAKE_CXX_STANDARD 17)
endif(${CMAKE_CXX_COMPILER} NOT STREQUAL "")

if(CMAKE_GENERATOR MATCHES "Unix Makefiles|Ninja")
# some LSP servers expect compile_commands.json in the project root
Expand Down

0 comments on commit ec85273

Please sign in to comment.