diff --git a/CMakeLists.txt b/CMakeLists.txt index e1c1adc..0cfd02c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,18 +1,19 @@ cmake_minimum_required(VERSION 3.20) -project("Chip-8" VERSION 0.1 LANGUAGES CXX C) +project("Chip-8" VERSION 0.1 LANGUAGES CXX) option(BUILD_SHARED_LIBS "Build shared libs" ON) option(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS "Export Windows symbols" ON) -if (MSVC) - message(WARNING "BUILD_SHARED_LIBS can't be used with MSVC") - set(BUILD_SHARED_LIBS OFF) -endif() +find_package(SDL2 REQUIRED) +find_package(SDL2_ttf REQUIRED) +find_package(fmt REQUIRED) +find_package(doctest REQUIRED) +find_package(cxxopts REQUIRED) +find_package(yaml-cpp REQUIRED) -include(cmake/dependencies.cmake) -include(cmake/copy_dll.cmake) include(cmake/compiler_flags.cmake) +include(cmake/copy_dll.cmake) enable_testing() # needed to create the target lib/test add_subdirectory(lib) add_subdirectory(chip-8-sdl) diff --git a/README.MD b/README.MD index abe6b3b..b4ac0ef 100644 --- a/README.MD +++ b/README.MD @@ -14,6 +14,6 @@ Requirements: - Cmake v3.20 or later ```console -cmake -B build -cmake --build build -``` \ No newline at end of file +conan install . --build=missing # on Linux, you might need to add these options -c tools.system.package_manager:mode=install -c tools.system.package_manager:sudo=True +conan build . +``` diff --git a/chip-8-disassembler/CMakeLists.txt b/chip-8-disassembler/CMakeLists.txt index 0b809a9..923262e 100644 --- a/chip-8-disassembler/CMakeLists.txt +++ b/chip-8-disassembler/CMakeLists.txt @@ -3,5 +3,5 @@ project("Chip-8 Disassembler" VERSION 0.1 LANGUAGES CXX) add_executable(chip-8-disassembler disas.cpp) target_include_directories(chip-8-disassembler PRIVATE ${CHIP8_INCLUDE_DIRS}) target_link_libraries(chip-8-disassembler PRIVATE chip-8 fmt::fmt) +copy_dll(chip-8-disassembler chip-8) enable_warnings(chip-8-disassembler) -copy_dll(chip-8-disassembler "chip-8;fmt") diff --git a/chip-8-sdl/CMakeLists.txt b/chip-8-sdl/CMakeLists.txt index 95a5369..1c3fff5 100644 --- a/chip-8-sdl/CMakeLists.txt +++ b/chip-8-sdl/CMakeLists.txt @@ -11,16 +11,19 @@ add_executable(chip-8-sdl widget/widget.cpp ) -if (WIN32) - set_target_properties(chip-8-sdl PROPERTIES WIN32_EXECUTABLE TRUE) - target_link_libraries(chip-8-sdl PRIVATE SDL2main) -endif() target_include_directories(chip-8-sdl PRIVATE ${CHIP8_INCLUDE_DIRS} ".") target_include_directories(chip-8-sdl SYSTEM PRIVATE "${cxxopts_SOURCE_DIR}/include") -target_link_libraries(chip-8-sdl PRIVATE chip-8 "$,SDL2,SDL2-static>" SDL2_ttf yaml-cpp fmt::fmt) +target_link_libraries(chip-8-sdl PRIVATE + chip-8 + SDL2::SDL2main + SDL2::SDL2-static + SDL2_ttf::SDL2_ttf-static + yaml-cpp + fmt::fmt + cxxopts::cxxopts +) +copy_dll(chip-8-sdl chip-8) enable_warnings(chip-8-sdl) -copy_dll(chip-8-sdl "SDL2;SDL2_ttf;chip-8;fmt;yaml-cpp") - get_filename_component(SOUND_FILE_PATH "res/audio/beep-02.wav" ABSOLUTE) get_filename_component(FONT_FILE_PATH "res/fonts/PressStart2P-Regular.ttf" ABSOLUTE) configure_file(configuration.yaml.in configuration.yaml) diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 0000000..eb5e46b --- /dev/null +++ b/conanfile.py @@ -0,0 +1,47 @@ +from conan import ConanFile +from conan.tools.cmake import CMakeToolchain, CMake, cmake_layout, CMakeDeps + +class Chip8Recipe(ConanFile): + name = "chip-8" + version = "0.1" + + author = "fpotier" + url = "https://github.com/fpotier/chip-8" + description = "Chip 8 emulator" + topics = ("chip-8", "emulator") + + settings = "os", "compiler", "build_type", "arch" + options = {"shared": [True, False], "fPIC": [True, False]} + default_options = {"shared": True, "fPIC": True} + + exports_sources = "CMakeLists.txt", "lib/*", "chip-8-sdl/*", "chip-8-disassembler", "cmake/*" + + def requirements(self): + self.requires("sdl/2.28.3") + self.requires("sdl_ttf/2.20.2") + self.requires("fmt/10.2.1") + self.requires("doctest/2.4.11") + self.requires("yaml-cpp/0.8.0") + self.requires("cxxopts/3.0.0") + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + + def layout(self): + cmake_layout(self) + + def generate(self): + deps = CMakeDeps(self) + deps.generate() + tc = CMakeToolchain(self) + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def package(self): + cmake = CMake(self) + cmake.install() diff --git a/lib/test/CMakeLists.txt b/lib/test/CMakeLists.txt index 56aa5b5..6d73abb 100644 --- a/lib/test/CMakeLists.txt +++ b/lib/test/CMakeLists.txt @@ -6,9 +6,8 @@ function(chip_8_test test_name) chip8_test.cpp ) target_include_directories(${test_name} PRIVATE ${CHIP8_INCLUDE_DIRS}) - target_link_libraries(${test_name} PRIVATE chip-8 doctest) + target_link_libraries(${test_name} PRIVATE chip-8 doctest::doctest) enable_warnings(${test_name}) - copy_dll(${test_name} "chip-8;fmt") add_test(NAME ${test_name} COMMAND ${test_name}) endfunction()