I have two different CMake builds: one with emscripten and one with regular g++. Based on the build type I want to execute certain c++ code blocks. I'm not sure how to do that.
CMAKE file:
cmake_minimum_required(VERSION 3.15)
project(project)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra")
if( ${CMAKE_SYSTEM_NAME} MATCHES "Emscripten")
# build with emscripten
else()
# build regularly
find_package(SDL2 REQUIRED)
find_package(Freetype REQUIRED)
endif()
include_directories(${CMAKE_SOURCE_DIR}/include ${SDL2_INCLUDE_DIRS} ${FREETYPE_INCLUDE_DIRS})
add_executable(project src/main.cpp src/glad.c src/Game.cpp)
target_link_libraries(project ${SDL2_LIBRARIES} ${FREETYPE_LIBRARIES})
In C++ I want to do the following:
if( not_emscripten_build ) {
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 3);
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
}