Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6905211
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:09:22+00:00 2026-05-27T08:09:22+00:00

I’m setting up my visual studio project to use CMake, but I got two

  • 0

I’m setting up my visual studio project to use CMake, but I got two issues I haven’t been able to solve yet.

1 How can I set a preprocessor define for Release and another for Debug?

2 I have a project with opengl and directx so for DebugOpenGL and ReleaseOpenGL i want to exclude all directx cpp/h files from the buld. With DebugDirectX and ReleaseDirectx exclude the opengl files. How do I set this up?

EDIT:

Heres what I got for 1. so far:

cmake_minimum_required(VERSION 2.8)

project(TEngine)

if(CMAKE_CONFIGURATION_TYPES AND MSVC)
#DebugOpenGL flags
set(CMAKE_CXX_FLAGS_DEBUGOPENGL "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1" CACHE STRING "Flags used by the C++ compiler during maintainer builds." FORCE)
set(CMAKE_C_FLAGS_DEBUGOPENGL "/D_DEBUG /MDd /Zi  /Ob0 /Od /RTC1" CACHE STRING "Flags used by the C compiler during maintainer builds." FORCE)
set(CMAKE_EXE_LINKER_FLAGS_DEBUGOPENGL "/debug /INCREMENTAL" CACHE STRING "Flags used for linking binaries during maintainer builds." FORCE )
set(CMAKE_SHARED_LINKER_FLAGS_DEBUGOPENGL "/debug /INCREMENTAL" CACHE STRING "Flags used by the shared libraries linker during maintainer builds." FORCE )

#ReleaseOpenGL flags
set(CMAKE_CXX_FLAGS_RELEASEOPENGL "/MD /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags used by the C++ compiler during maintainer builds." FORCE)
set(CMAKE_C_FLAGS_RELEASEOPENGL "/MD /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags used by the C compiler during maintainer builds." FORCE)
set(CMAKE_EXE_LINKER_FLAGS_RELEASEOPENGL "/INCREMENTAL:NO" CACHE STRING "Flags used for linking binaries during maintainer builds." FORCE )
set(CMAKE_SHARED_LINKER_FLAGS_RELEASEOPENGL "/INCREMENTAL:NO" CACHE STRING "Flags used by the shared libraries linker during maintainer builds." FORCE )

#DebugDirectX flags
set(CMAKE_CXX_FLAGS_DEBUGDIRECTX "/D_DEBUG /MDd /Zi /Ob0 /Od /RTC1" CACHE STRING "Flags used by the C++ compiler during maintainer builds." FORCE)
set(CMAKE_C_FLAGS_DEBUGDIRECTX "/D_DEBUG /MDd /Zi  /Ob0 /Od /RTC1" CACHE STRING "Flags used by the C compiler during maintainer builds." FORCE)
set(CMAKE_EXE_LINKER_FLAGS_DEBUGDIRECTX "/debug /INCREMENTAL" CACHE STRING "Flags used for linking binaries during maintainer builds." FORCE )
set(CMAKE_SHARED_LINKER_FLAGS_DEBUGDIRECTX "/debug /INCREMENTAL" CACHE STRING "Flags used by the shared libraries linker during maintainer builds." FORCE )

#ReleaseDirectx flags
set(CMAKE_CXX_FLAGS_RELEASEDIRECTX "/MD /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags used by the C++ compiler during maintainer builds." FORCE)
set(CMAKE_C_FLAGS_RELEASEDIRECTX "/MD /O2 /Ob2 /D NDEBUG" CACHE STRING "Flags used by the C compiler during maintainer builds." FORCE)
set(CMAKE_EXE_LINKER_FLAGS_RELEASEDIRECTX "/INCREMENTAL:NO" CACHE STRING "Flags used for linking binaries during maintainer builds." FORCE )
set(CMAKE_SHARED_LINKER_FLAGS_RELEASEDIRECTX "/INCREMENTAL:NO" CACHE STRING "Flags used by the shared libraries linker during maintainer builds." FORCE )

set(CMAKE_CONFIGURATION_TYPES "DebugOpenGL;ReleaseOpenGL;DebugDirectX;ReleaseDirectX")
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
"Reset the configurations to what we need"
FORCE)

if(CMAKE_BUILD_TYPE STREQUAL "DebugOpenGL")
    add_definitions(/DTE_USE_OPENGL)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "ReleaseOpenGL")
    add_definitions(/DTE_USE_OPENGL)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "DebugDirectX")
    add_definitions(/DTE_USE_OPENGL)
endif()
if(CMAKE_BUILD_TYPE STREQUAL "ReleaseDirectX")
    add_definitions(/DTE_USE_OPENGL)
endif()
endif()

set(Boost_ADDITIONAL_VERSIONS "1.47" "1.47.0")
set(BOOST_ROOT "${TEngine_SOURCE_DIR}/Externals/boost_1_47_0")

if(WIN32)
    add_definitions(-DTEWINDOWS)
elseif(LINUX)
    add_definitions(-DTELINUX -DTE_USE_OPENGL)
endif()

subdirs(TEEngineTest TECore TEGraphics TEPhysics TEngine)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T08:09:22+00:00Added an answer on May 27, 2026 at 8:09 am

    1:

    if(CMAKE_BUILD_TYPE STREQUAL "Debug")
      add_definitions(/DYOURDEFINITION)
    endif()
    

    2:
    If i understood you right, you need to create an option variable

    option(USE_OPENGL "Use OpenGL or DirectX")
    

    And then check for it when you are adding new target:

    if(USE_OPENGL)
    add_subdirectory(OpenGL)
    else()
    add_subdirectory(DirectX)
    endif()
    

    Of course, you should create CMakeLists.txt in OpenGL/ and DirectX/ dirs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I am trying to understand how to use SyndicationItem to display feed which is
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I want use html5's new tag to play a wav file (currently only supported
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.