Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions .github/workflows/test_windows.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Windows Test

on:
pull_request:
push:
branches:
- main

jobs:
cmake-test:
runs-on: windows-latest
strategy:
fail-fast: false
matrix:
configuration: [ 'Release', 'Debug' ]
build_shared_libs: ['OFF'] # Only static libraries supported on Windows

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Configure
run: |
cmake -S . -B build -DCUDD_BUILD_WITH_STATS=ON -DCUDD_BUILD_DDDMP=ON -DCUDD_BUILD_TESTS=ON -DCUDD_BUILD_SHARED_LIBS=${{ matrix.build_shared_libs }}

- name: Build
run: cmake --build build --config ${{ matrix.configuration }}

- name: Test
run: ctest --test-dir build --output-on-failure -C ${{ matrix.configuration }}

32 changes: 22 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
cmake_minimum_required(VERSION 3.10)

# Note: While this project supports CMake 3.10+, some features (like external
# dependencies via FetchContent) work best with CMake 3.14+. Compatibility
# workarounds are provided for older versions using ExternalProject.

# The default build type must be set before project()
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR AND NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type" FORCE)
Expand Down Expand Up @@ -31,7 +35,7 @@ include(GNUInstallDirs)
# Settings
# ============================================================================ #

option(CUDD_RECONFIGURE_SYSTEM "Configure system variables" OFF)
option(CUDD_RECONFIGURE_SYSTEM "Configure system variables" ON)
option(CUDD_BUILD_CPP_API "Build C++ API" ON)
option(CUDD_BUILD_SHARED_LIBS "Build CUDD as a shared library" OFF)
option(CUDD_BUILD_WITH_STATS "Build CUDD with statistics" OFF)
Expand All @@ -41,6 +45,16 @@ option(CUDD_BUILD_COVERAGE "Enable code coverage instrumentation" OFF)
# option(BUILD_API_DOCS "Build API documentation with Doxygen" OFF)
# option(BUILD_USER_GUIDES "Build user guides with LaTeX" OFF)

# Include platform-specific configuration
if(WIN32)
include(cmake/windows.cmake)
else()
include(cmake/unix.cmake)
endif()

# Check platform-specific shared library constraints
cudd_check_shared_libs()

# Use ucbqsort by default
set(USE_SYSTEM_QSORT FALSE)

Expand Down Expand Up @@ -170,6 +184,8 @@ if(CUDD_BUILD_SHARED_LIBS)
add_library(cudd SHARED ${CUDD_SOURCES})
else()
add_library(cudd STATIC ${CUDD_SOURCES})
# For static library builds, disable symbol import/export
target_compile_definitions(cudd PUBLIC CUDD_STATIC_DEFINE)
endif()
add_library(cudd::cudd ALIAS cudd)

Expand All @@ -178,12 +194,15 @@ target_compile_options(cudd PRIVATE
$<$<BOOL:${CUDD_BUILD_COVERAGE}>:--coverage>
)

cudd_configure_libraries(cudd)

# Include directories (build and install time)
target_include_directories(cudd PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/src>
)

# Define properties for the library
Expand Down Expand Up @@ -253,12 +272,5 @@ if(CUDD_BUILD_TESTS)
# add_subdirectory(extras/nanotrav)
endif()

# Compile Commands
if (PROJECT_IS_TOP_LEVEL AND UNIX)
# Create symlink to compile_commands.json for IDE to pick it up
execute_process(
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_BINARY_DIR}/compile_commands.json
${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json
)
endif()
# Configure platform-specific development tools
cudd_configure_dev_tools()
28 changes: 23 additions & 5 deletions cmake/cudd_configure_system.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,30 @@ CHECK_TYPE_SIZE("long double" SIZEOF_LONG_DOUBLE)
include(CheckFunctionExists)

set(CMAKE_REQUIRED_INCLUDES "math.h")
set(CMAKE_REQUIRED_LIBRARIES m)
# On Windows, math functions are built into the C runtime
# On Unix-like systems, we need to link with libm
if(NOT WIN32)
set(CMAKE_REQUIRED_LIBRARIES m)
endif()

CHECK_FUNCTION_EXISTS(pow HAVE_POW)
if(NOT (HAVE_POW))
message(FATAL_ERROR "'pow' function missing.")
if(NOT HAVE_POW)
if(WIN32)
message(STATUS "Setting HAVE_POW=1 for Windows platform")
set(HAVE_POW 1)
else()
message(FATAL_ERROR "'pow' function missing.")
endif()
endif()

CHECK_FUNCTION_EXISTS(sqrt HAVE_SQRT)
if(NOT (HAVE_SQRT))
message(FATAL_ERROR "'sqrt' function missing.")
if(NOT HAVE_SQRT)
if(WIN32)
message(STATUS "Setting HAVE_SQRT=1 for Windows platform")
set(HAVE_SQRT 1)
else()
message(FATAL_ERROR "'sqrt' function missing.")
endif()
endif()

CHECK_FUNCTION_EXISTS(strchr HAVE_STRCHR)
Expand All @@ -97,6 +111,10 @@ if(NOT (HAVE_STRSTR))
endif()

CHECK_FUNCTION_EXISTS(powl HAVE_POWL)
if(NOT HAVE_POWL AND WIN32)
message(STATUS "Setting HAVE_POWL=1 for Windows platform")
set(HAVE_POWL 1)
endif()
CHECK_FUNCTION_EXISTS(gethostname HAVE_GETHOSTNAME)
CHECK_FUNCTION_EXISTS(getrlimit HAVE_GETRLIMIT)
CHECK_FUNCTION_EXISTS(getrusage HAVE_GETRUSAGE)
Expand Down
49 changes: 49 additions & 0 deletions cmake/unix.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# Unix-specific CMake configuration for CUDD
# This file contains all Unix-specific build settings and configurations

# Configure shared library builds for Unix (no restrictions)
function(cudd_check_shared_libs)
# Unix platforms support shared libraries without issues
# No restrictions needed
endfunction()

# Configure C++11 support for Unix (non-MSVC compilers)
function(cudd_configure_cpp)
if(CUDD_BUILD_CPP_API)
# Check C++11 support for non-MSVC compilers (GCC, Clang, etc.)
if(NOT MSVC)
include(CheckCXXCompilerFlag)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
if(NOT COMPILER_SUPPORTS_CXX11)
message(FATAL_ERROR "${CMAKE_CXX_COMPILER} has no C++11 support.")
endif()
message(STATUS "C++11 support verified for ${CMAKE_CXX_COMPILER_ID}")
endif()
endif()
endfunction()

# Configure Unix-specific libraries (math library)
function(cudd_configure_libraries target_name)
# Link the math library (libm) on Unix-like systems
# On Windows, math functions are built into the C runtime
find_library(MATH_LIBRARY m)
if(MATH_LIBRARY)
target_link_libraries(${target_name} PUBLIC ${MATH_LIBRARY})
message(STATUS "Linking with math library: ${MATH_LIBRARY}")
else()
message(STATUS "Math library not found, assuming math functions are built-in")
endif()
endfunction()

# Configure Unix-specific development tools
function(cudd_configure_dev_tools)
if(PROJECT_IS_TOP_LEVEL AND UNIX)
# Create symlink to compile_commands.json for IDE to pick it up
execute_process(
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_BINARY_DIR}/compile_commands.json
${CMAKE_CURRENT_SOURCE_DIR}/compile_commands.json
)
message(STATUS "Created compile_commands.json symlink for IDE integration")
endif()
endfunction()
32 changes: 32 additions & 0 deletions cmake/windows.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Windows-specific CMake configuration for CUDD
# This file contains all Windows-specific build settings and configurations

# Block shared library builds on Windows due to DLL linkage issues
function(cudd_check_shared_libs)
if(CUDD_BUILD_SHARED_LIBS)
message(FATAL_ERROR "Shared library builds are not supported on Windows due to DLL linkage conflicts. Please use -DCUDD_BUILD_SHARED_LIBS=OFF for static library builds.")
endif()
endfunction()

# Configure C++11 support for Windows (MSVC)
function(cudd_configure_cpp)
if(CUDD_BUILD_CPP_API)
# MSVC automatically supports C++11 without needing explicit flags
if(MSVC)
message(STATUS "C++11 support verified for MSVC")
endif()
endif()
endfunction()

# Configure Windows-specific libraries
function(cudd_configure_libraries target_name)
# On Windows, link Winsock2 library for networking functions (gethostname, etc.)
target_link_libraries(${target_name} PUBLIC ws2_32)
message(STATUS "Linking with Windows Winsock2 library for networking functions")
endfunction()

# Configure Windows-specific development tools
function(cudd_configure_dev_tools)
# Windows doesn't need compile_commands.json symlink - IDEs handle it differently
# No-op function for consistency with Unix version
endfunction()
Loading