view cmake/MolkoSetCompilerFlags.cmake @ 295:aec448037320

rpg: add support for compressed tilesets/maps
author David Demelier <markand@malikania.fr>
date Wed, 10 Mar 2021 16:40:02 +0100
parents 97f55f6b9593
children
line wrap: on
line source

#
# CMakeLists.txt -- CMake build system for molko
#
# Copyright (c) 2020 David Demelier <markand@malikania.fr>
#
# Permission to use, copy, modify, and/or distribute this software for any
# purpose with or without fee is hereby granted, provided that the above
# copyright notice and this permission notice appear in all copies.
#
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
# WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
# ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
# OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#

#
# # molko_set_compiler_flags
#
# Set default compiler flags for the given target.
#
# ## Synopsis
#
# ```cmake
# molko_set_compiler_flags(target)
# ```
#
# This function will adds some compiler flags for the development such as
# warnings, sanitizers if the compiler is compatible.
#

function(molko_set_compiler_flags target)
	if (CMAKE_C_COMPILER_ID MATCHES "AppleClang|Clang|GNU")
		target_compile_options(${target} PRIVATE -Wall -Wextra)
	endif ()

	if (CMAKE_C_COMPILER_ID MATCHES "Clang")
		target_compile_options(${target} PRIVATE $<$<CONFIG:Debug>:-fsanitize=address,undefined,integer>)
		target_link_options(${target} PRIVATE $<$<CONFIG:Debug>:-fsanitize=address,undefined,integer>)
	endif ()
endfunction ()