Skip to content

Commit

Permalink
Workaround for a behaviour change (bug?) in cmake 3.18
Browse files Browse the repository at this point in the history
.c files are no longer forced to be compiled as C in the
Visual Studio generator, and Visual Studio seems to
"autodetect" some .c files as C++, which causes all sorts
of problems in the sokol-samples.

.c files are now 'manually' to C mode.
  • Loading branch information
floooh committed Jul 22, 2020
1 parent 3743db2 commit 89997b8
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion cmake/fips_private.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ macro(fips_add_file new_file)
else()
set(cur_file ${new_file})
endif()
get_filename_component(f_ext ${cur_file} EXT)
get_filename_component(f_ext ${cur_file} LAST_EXT)

# determine source group name and
# add to current source group
Expand All @@ -236,12 +236,24 @@ macro(fips_add_file new_file)
if (${f_ext} STREQUAL ".m")
set_source_files_properties(${cur_file} PROPERTIES LANGUAGE C)
endif()

# handle plist files special
if (${f_ext} STREQUAL ".plist")
set(FIPS_OSX_PLIST_PATH "${CMAKE_CURRENT_SOURCE_DIR}/${cur_file}")
endif()
endif()

# workaround for a regression in cmake 3.18 with Visual Studio Generator:
#
# Explicitely compile .c files as C, because cmake 3.18 changed behaviour
# and leaves the detection to Visual Studio, which seems to be broken
#
# NOTE that the more correct "PROPERTIES LANGUAGE C" doesn't appear to work.
#
if (FIPS_MSVC AND (${f_ext} STREQUAL ".c"))
set_source_files_properties(${cur_file} PROPERTIES COMPILE_OPTIONS "/TC")
endif()

# add to global tracker variables
list(APPEND CurSources ${cur_file})

Expand Down

0 comments on commit 89997b8

Please sign in to comment.