diff --git a/CMakeLists.txt b/CMakeLists.txt index c84d89a..e9de102 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,6 +4,8 @@ project(game_boy_emulator) set(CMAKE_CXX_STANDARD 20) option(SANITIZE "Enable address and undefined behavior sanitizers" ON) +option(TIDY "Enable clang-tidy checks" ON) +option(WARNINGS_ENABLED "Enable compiler warnings for all targets. Works for GNU and Clang." ON) find_package(fmt REQUIRED) find_package(Catch2 REQUIRED) @@ -22,7 +24,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules") set(CLANG_FORMAT_EXCLUDE_PATTERNS "src/bindings" ${CMAKE_BINARY_DIR}) find_package(ClangFormat) -if (CMAKE_CXX_COMPILER_ID STREQUAL Clang) +if (CMAKE_CXX_COMPILER_ID STREQUAL Clang AND TIDY) # The CMAKE_CXX_CLANG_TIDY integration passes all compiler arguments to clang-tidy. For gcc we have a required # compiler option to increase constexpr evaluation limit (fconstexpr-ops-limit), which clang does not know (it has # a different option). But this flag leads to cland-diagnostics-error and the workaround would be manually removing diff --git a/conanfile.py b/conanfile.py index b11d4c1..4c37bbf 100644 --- a/conanfile.py +++ b/conanfile.py @@ -1,5 +1,5 @@ from conans import ConanFile -from conan.tools.cmake import cmake_layout, CMakeDeps, CMakeToolchain +from conan.tools.cmake import cmake_layout, CMakeDeps, CMakeToolchain, CMake class GameBoyEmulatorConan(ConanFile): @@ -23,6 +23,9 @@ def requirements(self): # since there are warnins as errors. self.requires("gtk/system", override=True) + def export_sources(self): + self.copy("*", excludes=("build*", "cmake-build*")) + def layout(self): cmake_layout(self) @@ -42,5 +45,21 @@ def generate(self): deps.configuration = "Debug" deps.generate() + def build(self): + cmake = CMake(self) + # Since conan is mostly used for releases, we dont want sanitizers enabled and we dont want to run clang-tidy + # during the build since it is slow (and was run in CI for the commit already). + cmake.configure(variables={"SANITIZE": "OFF", "TIDY": "OFF"}) + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() + def imports(self): + # Copy the imgui bindings to the package self.copy("imgui_impl_sdl*", dst="bindings", src="res/bindings", root_package="imgui") + + def deploy(self): + # Copy just the executable from the cache to the local filesystem + self.copy("game_boy_emulator*", dst="", src="bin") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index df0f342..2ceb689 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -125,7 +125,7 @@ target_include_directories(game_boy_emulator bindings ) -option(WARNINGS_ENABLED "Enable compiler warnings for all targets. Works for GNU and Clang as well as MSVC." ON) +install(TARGETS game_boy_emulator) if (WARNINGS_ENABLED) target_compile_options(game_boy_emulator_library PRIVATE