From 7675c8360933162fa5dda4221d02c2cf7478edd7 Mon Sep 17 00:00:00 2001 From: Rodrigo Delduca Date: Mon, 30 Sep 2024 14:45:34 -0300 Subject: [PATCH] Work in progress --- CMakeLists.txt | 51 ++++++++++++++++++++++++-------------------------- src/common.hpp | 2 +- 2 files changed, 25 insertions(+), 28 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1fd4158..bbe7990 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,13 +1,11 @@ cmake_minimum_required(VERSION 3.20) -project(carimbo) +project(carimbo LANGUAGES CXX) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(SDL2_MAIN SDL2::SDL2main) - find_package(CURL CONFIG REQUIRED) find_package(fmt CONFIG REQUIRED) find_package(Ogg CONFIG REQUIRED) @@ -25,41 +23,38 @@ file(GLOB SOURCE_FILES "src/*.cpp") add_executable(${PROJECT_NAME} ${SOURCE_FILES}) target_precompile_headers(${PROJECT_NAME} PRIVATE ${HEADER_FILES}) -option(SANDBOX "Use sandbox" OFF) - -if(SANDBOX) - add_definitions(-DSANDBOX) -endif() - -if (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") - target_link_libraries(${PROJECT_NAME} PRIVATE "-s EVAL_CTORS=1") - target_link_libraries(${PROJECT_NAME} PRIVATE "-s WASM_BIGINT=1") - target_link_libraries(${PROJECT_NAME} PRIVATE "-s DISABLE_EXCEPTION_CATCHING=1") - target_link_libraries(${PROJECT_NAME} PRIVATE "-s ALLOW_MEMORY_GROWTH=1") - target_link_libraries(${PROJECT_NAME} PRIVATE "-s INITIAL_MEMORY=134217728") - target_link_libraries(${PROJECT_NAME} PRIVATE "-s EXPORTED_RUNTIME_METHODS=['callMain']") - # target_link_libraries(${PROJECT_NAME} PRIVATE "-s USE_PTHREADS=1" "-pthread") - - # target_link_libraries(${PROJECT_NAME} PRIVATE "--profiling") - # target_link_libraries(${PROJECT_NAME} PRIVATE "-s RUNTIME_DEBUG") - # target_link_libraries(${PROJECT_NAME} PRIVATE "-s ASSERTIONS=1") - # target_link_libraries(${PROJECT_NAME} PRIVATE "-s NO_DISABLE_EXCEPTION_CATCHING") - target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror -pedantic -O3 -flto) -elseif(CMAKE_BUILD_TYPE MATCHES "Debug") +if(CMAKE_BUILD_TYPE MATCHES "Debug") if (MSVC) target_compile_options(${PROJECT_NAME} PRIVATE /W4 /Od /Zi) else() target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror -O0 -g) endif() -elseif (CMAKE_BUILD_TYPE MATCHES "Release") +elseif(CMAKE_BUILD_TYPE MATCHES "Release") if (MSVC) - target_compile_options(${PROJECT_NAME} PRIVATE /W4 /O3 /GL) + target_compile_options(${PROJECT_NAME} PRIVATE /W4 /O2 /GL) else() target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror -pedantic -O3 -flto) endif() endif() -configure_file(${CMAKE_SOURCE_DIR}/assets/index.html ${CMAKE_BINARY_DIR}/index.html COPYONLY) +if (${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") + set(EMSCRIPTEN_OPTIONS + "-s EVAL_CTORS=1" + "-s WASM_BIGINT=1" + "-s DISABLE_EXCEPTION_CATCHING=1" + "-s ALLOW_MEMORY_GROWTH=1" + "-s INITIAL_MEMORY=134217728" + "-s EXPORTED_RUNTIME_METHODS=['callMain']" + ) + + target_link_libraries(${PROJECT_NAME} PRIVATE ${EMSCRIPTEN_OPTIONS}) + target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -Werror -pedantic -O3 -flto) +endif() + +option(SANDBOX "Use sandbox" OFF) +if(SANDBOX) + target_compile_definitions(${PROJECT_NAME} PRIVATE -DSANDBOX) +endif() target_link_libraries(${PROJECT_NAME} PRIVATE CURL::libcurl @@ -77,3 +72,5 @@ target_link_libraries(${PROJECT_NAME} PRIVATE if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten") target_link_libraries(${PROJECT_NAME} PRIVATE OpenAL::OpenAL) endif() + +configure_file(${CMAKE_SOURCE_DIR}/assets/index.html ${CMAKE_BINARY_DIR}/index.html COPYONLY) diff --git a/src/common.hpp b/src/common.hpp index 179ee34..e345cf3 100644 --- a/src/common.hpp +++ b/src/common.hpp @@ -9,7 +9,7 @@ extern "C" { #include #include -// #include +#include #include #include #include