diff --git a/CMakeLists.txt b/CMakeLists.txt index 57add3be..30155098 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,26 +30,6 @@ if(WIN32) endif() option(SMW_INSTALL_PORTABLE "Install to a single directory" ${SMW_INSTALL_PORTABLE_DEFAULT}) -if (USE_SDL2_LIBS) - add_definitions(-DUSE_SDL2) - - if (SDL2_USE_MIXERX) - add_definitions(-DSDL2_USE_MIXERX) - endif() - - if (SDL2_FORCE_GLES) - add_definitions(-DSDL2_FORCE_GLES) - endif() -endif() - -if (NO_NETWORK) - add_definitions(-DNETWORK_DISABLED) -endif() - -if (USE_PNG_SAVE) - add_definitions(-DPNG_SAVE_FORMAT) -endif() - # Additional CMake search path set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/") diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 65b9646b..2348052d 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -41,6 +41,21 @@ if (USE_PNG_SAVE AND NOT USE_SDL2_LIBS) endif() +if (USE_SDL2_LIBS) + target_compile_definitions(CommonFiles PUBLIC USE_SDL2) + + if (SDL2_FORCE_GLES) + target_compile_definitions(CommonFiles PUBLIC SDL2_FORCE_GLES) + endif() + if (SDL2_USE_MIXERX) + target_compile_definitions(CommonFiles PUBLIC SDL2_USE_MIXERX) + endif() +endif() +if (USE_PNG_SAVE) + target_compile_definitions(CommonFiles PUBLIC PNG_SAVE_FORMAT) +endif() + + if(NOT EMSCRIPTEN) if (USE_SDL2_LIBS) target_link_libraries(CommonFiles diff --git a/src/smw/CMakeLists.txt b/src/smw/CMakeLists.txt index 9049505b..0e201c3c 100644 --- a/src/smw/CMakeLists.txt +++ b/src/smw/CMakeLists.txt @@ -110,7 +110,9 @@ target_sources(smw PRIVATE ui/MI_NetRoomTeamSelect.cpp ) -if(NOT NO_NETWORK) +if(NO_NETWORK) + target_compile_definitions(smw PRIVATE NETWORK_DISABLED) +else() target_sources(smw PRIVATE platform/network/enet/NetworkLayerENet.cpp) endif()