diff --git a/.github/workflows/test_windows.yml b/.github/workflows/test_windows.yml new file mode 100644 index 00000000..dc547f7a --- /dev/null +++ b/.github/workflows/test_windows.yml @@ -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 }} + diff --git a/CMakeLists.txt b/CMakeLists.txt index cf9838eb..642ed58e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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) @@ -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) @@ -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) @@ -178,12 +194,15 @@ target_compile_options(cudd PRIVATE $<$:--coverage> ) +cudd_configure_libraries(cudd) + # Include directories (build and install time) target_include_directories(cudd PUBLIC $ $ $ $ + $ ) # Define properties for the library @@ -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() diff --git a/cmake/cudd_configure_system.cmake b/cmake/cudd_configure_system.cmake index f20274ca..97c84128 100644 --- a/cmake/cudd_configure_system.cmake +++ b/cmake/cudd_configure_system.cmake @@ -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) @@ -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) diff --git a/cmake/unix.cmake b/cmake/unix.cmake new file mode 100644 index 00000000..efb722cb --- /dev/null +++ b/cmake/unix.cmake @@ -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() diff --git a/cmake/windows.cmake b/cmake/windows.cmake new file mode 100644 index 00000000..f16b0eef --- /dev/null +++ b/cmake/windows.cmake @@ -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() \ No newline at end of file diff --git a/src/config.h b/src/config.h deleted file mode 100644 index 531307b0..00000000 --- a/src/config.h +++ /dev/null @@ -1,192 +0,0 @@ -/* Define to 1 if you have the header file. */ -#define HAVE_ASSERT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_FLOAT_H 1 - -/* Define to 1 if you have the `gethostname' function. */ -#define HAVE_GETHOSTNAME 1 - -/* Define to 1 if you have the `getrlimit' function. */ -#define HAVE_GETRLIMIT 1 - -/* Define to 1 if you have the `getrusage' function. */ -#define HAVE_GETRUSAGE 1 - -/* Define if you have working floating-point infinities */ -#define HAVE_IEEE_754 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_LIMITS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MATH_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 - -/* Define to 1 if your compiler supports enough C++11 */ -#define HAVE_MODERN_CXX 1 - -/* Define to 1 if you have the `pow' function. */ -#define HAVE_POW 1 - -/* Define to 1 if you have the `powl' function. */ -#define HAVE_POWL 1 - -/* Define to 1 if the system has the type `ptrdiff_t'. */ -#define HAVE_PTRDIFF_T 1 - -/* Define to 1 if you have the `sqrt' function. */ -#define HAVE_SQRT 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDDEF_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 - -/* Define to 1 if you have the `strchr' function. */ -#define HAVE_STRCHR 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* Define to 1 if you have the `strstr' function. */ -#define HAVE_STRSTR 1 - -/* Define to 1 if you have the `sysconf' function. */ -#define HAVE_SYSCONF 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_RESOURCE_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIMES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIME_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_SYS_WAIT_H 1 - -/* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 - -/* Define to 1 if C++ thread header is usable */ -#define HAVE_WORKING_THREAD 1 - -/* Define to 1 if the system has the type `_Bool'. */ -#define HAVE__BOOL 1 - -/* Define to the sub-directory in which libtool stores uninstalled libraries. - */ -/* #undef LT_OBJDIR */ - -/* Name of package */ -#define PACKAGE "cudd" - -/* Define to the address where bug reports for this package should be sent. */ -#define PACKAGE_BUGREPORT "Fabio@Colorado.EDU" - -/* Define to the full name of this package. */ -#define PACKAGE_NAME "cudd" - -/* Define to the full name and version of this package. */ -#define PACKAGE_STRING "cudd " - -/* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "cudd" - -/* Define to the home page for this package. */ -#define PACKAGE_URL "" - -/* Define to the version of this package. */ -#define PACKAGE_VERSION "3.0.0" - -/* The size of `int', as computed by sizeof. */ -#define SIZEOF_INT 4 - -/* The size of `long', as computed by sizeof. */ -#define SIZEOF_LONG 8 - -/* The size of `long double', as computed by sizeof. */ -#define SIZEOF_LONG_DOUBLE 16 - -/* The size of `void *', as computed by sizeof. */ -#define SIZEOF_VOID_P 8 - -/* Define to 1 if you have the ANSI C header files. */ -#define STDC_HEADERS 1 - -/* Define to use system qsort */ -/* #undef USE_SYSTEM_QSORT */ - -/* Version number of package */ -#define VERSION "" - -/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most - significant byte first (like Motorola and SPARC, unlike Intel). */ -#if defined AC_APPLE_UNIVERSAL_BUILD -# if defined __BIG_ENDIAN__ -# define WORDS_BIGENDIAN 1 -# endif -#else -# ifndef WORDS_BIGENDIAN -/* #undef WORDS_BIGENDIAN */ -# endif -#endif - -/* Define for Solaris 2.5.1 so the uint32_t typedef from , - , or is not used. If the typedef were allowed, the - #define below would cause a syntax error. */ -/* #undef _UINT32_T */ - -/* Define to 1 to enable C99-compliant printf on MinGW-w64 */ -/* #undef __USE_MINGW_ANSI_STDIO */ - -/* Define to `__inline__' or `__inline' if that's what the C compiler - calls it, or to nothing if 'inline' is not supported under any name. */ -#ifndef __cplusplus -/* #undef inline */ -#endif - -/* Define to `unsigned int' if does not define. */ -/* #undef size_t */ - -/* Define to the type of an unsigned integer type of width exactly 16 bits if - such a type exists and the standard includes do not define it. */ -/* #undef uint16_t */ - -/* Define to the type of an unsigned integer type of width exactly 32 bits if - such a type exists and the standard includes do not define it. */ -/* #undef uint32_t */ - - -#if defined _WIN32 || defined __CYGWIN__ - #ifdef CUDD_BUILDING_DLL - #define CUDD_API __declspec(dllexport) - #else - #define CUDD_API __declspec(dllimport) - #endif -#else - #define CUDD_API __attribute__((visibility("default"))) -#endif