Skip to content
Merged
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
56 changes: 7 additions & 49 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ cmake_minimum_required(VERSION 3.20)
# Project config
project(cupdlpx LANGUAGES C CXX CUDA)

set(CUPDLPX_VERSION_MAJOR 0)
set(CUPDLPX_VERSION_MINOR 1)
set(CUPDLPX_VERSION_PATCH 3)

set(CUPDLPX_VERSION "${CUPDLPX_VERSION_MAJOR}.${CUPDLPX_VERSION_MINOR}.${CUPDLPX_VERSION_PATCH}")
add_compile_definitions(CUPDLPX_VERSION="${CUPDLPX_VERSION}")

set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)

# C/C++ standards
Expand Down Expand Up @@ -65,52 +72,6 @@ if (CUPDLPX_BUILD_PYTHON)
find_package(Python3 COMPONENTS Interpreter REQUIRED) # For versioning script and pybind11
endif()

# -----------------------------------------------------------------------------
# VERSION HEADER GENERATION (Build/generated/version.h)
# -----------------------------------------------------------------------------
if (CUPDLPX_BUILD_PYTHON)
# Extract version from pyproject.toml (Requires Python3_EXECUTABLE)
execute_process(
COMMAND ${Python3_EXECUTABLE} -c
[=[
import sys
try:
import tomllib as toml
except ModuleNotFoundError:
import tomli as toml
import os

if not os.path.exists("pyproject.toml"):
sys.stderr.write("Error: pyproject.toml not found in the root directory.\n")
sys.exit(1)

with open("pyproject.toml", "rb") as f:
data = toml.load(f)
ver = data["project"]["version"]
print(ver)
]=]
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
OUTPUT_VARIABLE CUPDLPX_VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "cuPDLPx version from pyproject.toml = ${CUPDLPX_VERSION}")
else()
# Set a fallback version when Python is not used (suitable for Yggdrasil builds)
set(CUPDLPX_VERSION "0.0.0-core-only")
message(STATUS "cuPDLPx version (core only) = ${CUPDLPX_VERSION}")
endif()

# Generate version.h from version.h.in
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/version.h.in
${CMAKE_CURRENT_BINARY_DIR}/generated/version.h
@ONLY
)

# Make the generated files available for inclusion
include_directories(${CMAKE_CURRENT_BINARY_DIR}/generated)


# -----------------------------------------------------------------------------
# SOURCE DISCOVERY & TARGET DEFINITION
# -----------------------------------------------------------------------------
Expand All @@ -128,7 +89,6 @@ list(REMOVE_ITEM C_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/cli.c")
set(CORE_INCLUDE_DIRS
PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include # Public API headers
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/internal # Internal implementation headers
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/generated # Generated headers (version.h)
)

# Set common link libraries
Expand Down Expand Up @@ -190,7 +150,6 @@ if(CUPDLPX_BUILD_CLI)
target_include_directories(cupdlpx_cli PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/internal
${CMAKE_CURRENT_BINARY_DIR}/generated
)

# Link CLI to the static core library
Expand Down Expand Up @@ -230,7 +189,6 @@ if(CUPDLPX_BUILD_TESTS)
target_include_directories(${TEST_NAME}
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include
PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/internal
PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/generated
)

# Tests are final executables, they must resolve device symbols
Expand Down
5 changes: 4 additions & 1 deletion src/utils.cu
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,13 @@ limitations under the License.
*/

#include "utils.h"
#include "version.h"
#include <math.h>
#include <random>

#ifndef CUPDLPX_VERSION
#define CUPDLPX_VERSION "unknown"
#endif

std::mt19937 gen(1);
std::normal_distribution<double> dist(0.0, 1.0);

Expand Down
19 changes: 0 additions & 19 deletions version.h.in

This file was deleted.