Skip to content

FemboyValve/vpc_cmake

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vpc.cmake

A CMake utility to emulate VPC-style conditional file inclusion in a build system. This allows you to specify source files and associate them with platform-specific or user-defined conditions in a flexible and readable way.

Features

  • Conditional inclusion of source files using standard platform flags or custom variables
  • Support for logical operations: AND, OR, and NOT
  • Clean and extendable function structure
  • Optional debugging output to verify which files are being included

Usage

Include vpc.cmake in your CMakeLists.txt:

include(path/to/vpc.cmake)

Use vpc_file to create a conditional list of files:

vpc_file(SOURCES
    src/main.cpp
    src/windows_specific.cpp WIN32
    src/linux_specific.cpp UNIX AND NOT APPLE
    src/macos_specific.mm APPLE
    src/experimental.cpp ENABLE_EXPERIMENTAL_FEATURE
)
add_executable(MyApp ${SOURCES})

Debugging

To print the selected files during configuration, use vpc_file_debug:

vpc_file_debug(SOURCES
    src/main.cpp
    src/debug_only.cpp ENABLE_DEBUG
)

Defining Conditions

You can use standard CMake variables like:

  • WIN32
  • UNIX
  • APPLE
  • MSVC

You can also define your own conditions:

option(ENABLE_EXPERIMENTAL_FEATURE "Enable experimental features" OFF)

And use them:

vpc_file(SOURCES
    src/experimental.cpp ENABLE_EXPERIMENTAL_FEATURE
)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages