Skip to content

Commit

Permalink
Improved CMakeLists files.
Browse files Browse the repository at this point in the history
  • Loading branch information
5cript committed Jan 19, 2024
1 parent ea65f03 commit f400753
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 14 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ include (${CMAKE_CURRENT_LIST_DIR}/_cmake/common_options.cmake)

# Add executable (sources are added later, depending on frontend/backend)
add_executable(${PROJECT_NAME})
set_common_options(${PROJECT_NAME})
target_link_libraries(${PROJECT_NAME} PUBLIC core-target)

set(PREJS_FILE ${CMAKE_SOURCE_DIR}/frontend/source/frontend/js/module.js)

if (EMSCRIPTEN)
if (EMSCRIPTEN)
add_subdirectory(${CMAKE_SOURCE_DIR}/frontend/source/frontend)
else()
add_subdirectory(${CMAKE_SOURCE_DIR}/backend/source/backend)
Expand Down
22 changes: 10 additions & 12 deletions _cmake/common_options.cmake
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
function(set_common_options TARGET)
if (${MSVC})
set(WARNINGS -Wmost)
else()
set(WARNINGS -Wall -Wextra -Wpedantic)
endif()
set(COMMON_OPTIONS ${WARNINGS} -fexceptions -pedantic -fconstexpr-steps=1271242)
set(DEBUG_OPTIONS -g ${COMMON_OPTIONS})
set(RELEASE_OPTIONS -O3 ${COMMON_OPTIONS})
target_compile_options(${TARGET} PUBLIC "$<$<CONFIG:DEBUG>:${DEBUG_OPTIONS}>")
target_compile_options(${TARGET} PUBLIC "$<$<CONFIG:RELEASE>:${RELEASE_OPTIONS}>")
endfunction()
add_library(core-target INTERFACE)

if (${MSVC})
target_compile_options(core-target INTERFACE -Wmost)
else()
target_compile_options(core-target INTERFACE -Wall -Wextra -Wpedantic)
endif()
target_compile_options(core-target INTERFACE -fexceptions -pedantic $<$<CONFIG:DEBUG>:-g;-Werror=return-type> $<$<CONFIG:RELEASE>:-O3>)
target_link_options(core-target INTERFACE $<$<CONFIG:RELEASE>:-s;-static-libgcc;-static-libstdc++>)
target_compile_features(core-target INTERFACE cxx_std_20)

0 comments on commit f400753

Please sign in to comment.