Skip to content

Commit a47bd2f

Browse files
authored
Merge pull request #2286 from ERGO-Code/cmake
CMake updates
2 parents ccf22bd + 9b8de43 commit a47bd2f

File tree

452 files changed

+735
-760
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

452 files changed

+735
-760
lines changed

.github/workflows/build-meson.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@ jobs:
4545
# run: |
4646
# meson configure bbdir -Dwith_pybind11=True
4747
# meson compile -C bbdir
48-
# LD_LIBRARY_PATH=$(pwd)/bbdir/src \
48+
# LD_LIBRARY_PATH=$(pwd)/bbdir/highs \
4949
# PYTHONPATH=$(pwd)/bbdir \
5050
# python examples/call_highs_from_python.py

.github/workflows/clang-format.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- uses: DoozyX/[email protected]
1212
with:
1313
source:
14-
'app/ src/Highs.h ./src/lp_data ./src/mip ./src/model ./src/simplex ./src/presolve ./src/simplex ./src/util ./src/test ./src/qpsolver'
15-
# ./src/test ./interfaces'
14+
'app/ highs/Highs.h ./highs/lp_data ./highs/mip ./highs/model ./highs/simplex ./highs/presolve ./highs/simplex ./highs/util ./highs/test_kkt ./highs/qpsolver'
15+
# ./highs/test_kkt ./interfaces'
1616
extensions: 'h,cpp,c'
1717
clangFormatVersion: 18

.github/workflows/code-coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
lcov --remove cov.info "extern/zstr/*" -o cov.info
4646
lcov --remove cov.info "extern/catch*" -o cov.info
4747
lcov --remove cov.info "app/CLI11*" -o cov.info
48-
lcov --remove cov.info "src/test*" -o cov.info
48+
lcov --remove cov.info "highs/test_kkt*" -o cov.info
4949
lcov --list cov.info
5050
mv cov.info coverage.info
5151

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ cov.info
250250
#SCIP interface
251251
lpi_highs.cpp
252252

253-
src/highspy/highs_bindings.*.so
253+
highs/highspy/highs_bindings.*.so
254254

255255
# Model written with HiGHSDEV=on
256256
HighsRunModel.mps

BUILD.bazel

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_binary", "cc_test")
33

44
copy_file(
55
name = "highs-config",
6-
src = "src/HConfig.h.bazel.in",
6+
src = "highs/HConfig.h.bazel.in",
77
out = "HConfig.h",
88
visibility = ["//visibility:public"],
99
)
@@ -18,27 +18,27 @@ cc_library(
1818
name = "highs",
1919
srcs = glob([
2020
"extern/filereaderlp/*.cpp",
21-
"src/interfaces/highs_c_api.cpp",
22-
"src/io/*.cpp",
23-
"src/ipm/*.cpp",
24-
"src/ipm/ipx/*.cc",
25-
"src/ipm/basiclu/*.c",
26-
"src/lp_data/*.cpp",
27-
"src/mip/*.cpp",
28-
"src/model/*.cpp",
29-
"src/parallel/*.cpp",
30-
"src/pdlp/*.cpp",
31-
"src/pdlp/cupdlp/*.c",
32-
"src/presolve/*.cpp",
33-
"src/qpsolver/*.cpp",
34-
"src/simplex/*.cpp",
35-
"src/test/*.cpp",
36-
"src/util/*.cpp",
21+
"highs/interfaces/highs_c_api.cpp",
22+
"highs/io/*.cpp",
23+
"highs/ipm/*.cpp",
24+
"highs/ipm/ipx/*.cc",
25+
"highs/ipm/basiclu/*.c",
26+
"highs/lp_data/*.cpp",
27+
"highs/mip/*.cpp",
28+
"highs/model/*.cpp",
29+
"highs/parallel/*.cpp",
30+
"highs/pdlp/*.cpp",
31+
"highs/pdlp/cupdlp/*.c",
32+
"highs/presolve/*.cpp",
33+
"highs/qpsolver/*.cpp",
34+
"highs/simplex/*.cpp",
35+
"highs/test_kkt/*.cpp",
36+
"highs/util/*.cpp",
3737
]),
3838
hdrs = glob([
3939
"**/*.h",
40-
"src/qpsolver/*.hpp",
41-
"src/Highs.h",
40+
"highs/qpsolver/*.hpp",
41+
"highs/Highs.h",
4242
"extern/filereaderlp/*.hpp",
4343
"extern/zstr/*.hpp",
4444
]),
@@ -50,19 +50,19 @@ cc_library(
5050
"extern",
5151
# "extern/filereaderlp",
5252
# "extern/zstr",
53-
"src",
54-
# "src/ipm",
55-
# "src/ipm/ipx",
56-
# "src/ipm/basiclu",
57-
# "src/lp_data",
58-
# "src/mip",
59-
# "src/model",
60-
# "src/parallel",
61-
# "src/presolve",
62-
# "src/qpsolver",
63-
# "src/simplex",
64-
# "src/test",
65-
# "src/util",
53+
"highs",
54+
# "highs/ipm",
55+
# "highs/ipm/ipx",
56+
# "highs/ipm/basiclu",
57+
# "highs/lp_data",
58+
# "highs/mip",
59+
# "highs/model",
60+
# "highs/parallel",
61+
# "highs/presolve",
62+
# "highs/qpsolver",
63+
# "highs/simplex",
64+
# "highs/test_kkt",
65+
# "highs/util",
6666
"bazel-bin",
6767
],
6868
linkopts = ["-lpthread"],

CMakeLists.txt

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,14 @@ option(FAST_BUILD "Fast build: " ON)
4040

4141
find_program(GIT git)
4242

43-
if((GIT) AND(EXISTS ${HIGHS_SOURCE_DIR}/.git))
43+
if((GIT) AND(EXISTS ${PROJECT_SOURCE_DIR}/.git))
4444
execute_process(
4545
COMMAND ${GIT} status
46-
WORKING_DIRECTORY ${HIGHS_SOURCE_DIR} OUTPUT_QUIET)
46+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} OUTPUT_QUIET)
4747

4848
execute_process(
4949
COMMAND ${GIT} describe --always
50-
WORKING_DIRECTORY ${HIGHS_SOURCE_DIR}
50+
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
5151
OUTPUT_VARIABLE GITHASH OUTPUT_STRIP_TRAILING_WHITESPACE)
5252
# string(REGEX REPLACE "^.*-g" "" GITHASH ${GITHASH})
5353
else()
@@ -72,6 +72,9 @@ message(STATUS "Git hash: " ${GITHASH})
7272
option(BUILD_CXX "Build C++ library" ON)
7373
message(STATUS "Build C++ library: ${BUILD_CXX}")
7474

75+
option(BUILD_CXX_EXE "Build C++ executable" ON)
76+
message(STATUS "Build C++ library: ${BUILD_CXX_EXE}")
77+
7578
option(BUILD_TESTING "Build Tests" ON)
7679

7780
option(FORTRAN "Build Fortran interface" OFF)
@@ -463,10 +466,7 @@ if(MSVC)
463466
# add_link_options("/DEBUG:FASTLINK")
464467

465468
add_compile_options("$<$<COMPILE_LANGUAGE:C,CXX>:/Z7>")
466-
467-
if (NOT CUPDLP_GPU)
468-
add_compile_options("$<$<COMPILE_LANGUAGE:C,CXX>:/DEBUG:FASTLINK>")
469-
endif()
469+
add_link_options("$<$<COMPILE_LANGUAGE:C,CXX>:/DEBUG:FASTLINK>")
470470

471471
if(STDCALL)
472472
# /Gz - stdcall calling convention
@@ -518,7 +518,7 @@ set(CPACK_PACKAGE_VENDOR "University of Edinburgh")
518518
# string(TIMESTAMP TODAY "%Y-%m-%d")
519519
# message(STATUS "Compilation date: " ${TODAY})
520520

521-
configure_file(${HIGHS_SOURCE_DIR}/src/HConfig.h.in ${HIGHS_BINARY_DIR}/HConfig.h)
521+
configure_file(${PROJECT_SOURCE_DIR}/highs/HConfig.h.in ${HIGHS_BINARY_DIR}/HConfig.h)
522522

523523
if (DEBUG_MEMORY STREQUAL "Address")
524524
set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} \
@@ -676,7 +676,7 @@ if(NOT FAST_BUILD)
676676
COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --zerocounters
677677
COMMAND ${LCOV_PATH} --capture --initial --directory ${CMAKE_BINARY_DIR}/bin --output-file ${CMAKE_BINARY_DIR}/coverage.info
678678
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR} ${CMAKE_CTEST_COMMAND} -LE "(LONG|FAIL)" || true
679-
COMMAND ${LCOV_PATH} --capture --directory ${CMAKE_BINARY_DIR}/bin --directory ${CMAKE_BINARY_DIR}/src --directory ${CMAKE_BINARY_DIR}/app --directory ${CMAKE_BINARY_DIR}/check --output-file ${CMAKE_BINARY_DIR}/coverage.info
679+
COMMAND ${LCOV_PATH} --capture --directory ${CMAKE_BINARY_DIR}/bin --directory ${CMAKE_BINARY_DIR}/highs --directory ${CMAKE_BINARY_DIR}/app --directory ${CMAKE_BINARY_DIR}/check --output-file ${CMAKE_BINARY_DIR}/coverage.info
680680
COMMAND ${LCOV_PATH} --remove "*/usr/include/*" --output-file ${CMAKE_BINARY_DIR}/coverage.info.cleaned
681681
COMMAND ${GENHTML_PATH} -o ${CMAKE_BINARY_DIR}/coverage ${CMAKE_BINARY_DIR}/coverage.info.cleaned
682682
COMMAND ${CMAKE_COMMAND} -E remove ${CMAKE_BINARY_DIR}/coverage.info.cleaned
@@ -690,7 +690,7 @@ if(NOT FAST_BUILD)
690690
COMMAND ${LCOV_PATH} --directory ${CMAKE_BINARY_DIR} --zerocounters
691691
COMMAND ${LCOV_PATH} --capture --initial --directory ${CMAKE_BINARY_DIR}/bin --output-file ${CMAKE_BINARY_DIR}/coverage.info
692692
COMMAND ${CMAKE_COMMAND} -E chdir ${CMAKE_BINARY_DIR} ${CMAKE_CTEST_COMMAND} -LE "(LONG|FAIL)" || true
693-
COMMAND ${LCOV_PATH} --capture --directory ${CMAKE_BINARY_DIR}/bin --directory ${CMAKE_BINARY_DIR}/src --directory ${CMAKE_BINARY_DIR}/app --directory ${CMAKE_BINARY_DIR}/check --output-file ${CMAKE_BINARY_DIR}/coverage.info
693+
COMMAND ${LCOV_PATH} --capture --directory ${CMAKE_BINARY_DIR}/bin --directory ${CMAKE_BINARY_DIR}/highs --directory ${CMAKE_BINARY_DIR}/app --directory ${CMAKE_BINARY_DIR}/check --output-file ${CMAKE_BINARY_DIR}/coverage.info
694694
VERBATIM
695695
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
696696
COMMENT "Resetting code coverage counters to zero.")
@@ -699,22 +699,22 @@ if(NOT FAST_BUILD)
699699

700700
include_directories(
701701
${HIGHS_BINARY_DIR}
702-
${HIGHS_SOURCE_DIR}/app
703-
${HIGHS_SOURCE_DIR}/extern
704-
${HIGHS_SOURCE_DIR}/extern/zstr
705-
${HIGHS_SOURCE_DIR}/src
706-
${HIGHS_SOURCE_DIR}/src/io
707-
${HIGHS_SOURCE_DIR}/src/pdlp/cupdlp
708-
${HIGHS_SOURCE_DIR}/src/ipm/ipx
709-
${HIGHS_SOURCE_DIR}/src/ipm/basiclu
710-
${HIGHS_SOURCE_DIR}/src/lp_data
711-
${HIGHS_SOURCE_DIR}/src/mip
712-
${HIGHS_SOURCE_DIR}/src/model
713-
${HIGHS_SOURCE_DIR}/src/presolve
714-
${HIGHS_SOURCE_DIR}/src/qpsolver
715-
${HIGHS_SOURCE_DIR}/src/simplex
716-
${HIGHS_SOURCE_DIR}/src/test
717-
${HIGHS_SOURCE_DIR}/src/util)
702+
${PROJECT_SOURCE_DIR}/app
703+
${PROJECT_SOURCE_DIR}/extern
704+
${PROJECT_SOURCE_DIR}/extern/zstr
705+
${PROJECT_SOURCE_DIR}/highs
706+
${PROJECT_SOURCE_DIR}/highs/io
707+
${PROJECT_SOURCE_DIR}/highs/pdlp/cupdlp
708+
${PROJECT_SOURCE_DIR}/highs/ipm/ipx
709+
${PROJECT_SOURCE_DIR}/highs/ipm/basiclu
710+
${PROJECT_SOURCE_DIR}/highs/lp_data
711+
${PROJECT_SOURCE_DIR}/highs/mip
712+
${PROJECT_SOURCE_DIR}/highs/model
713+
${PROJECT_SOURCE_DIR}/highs/presolve
714+
${PROJECT_SOURCE_DIR}/highs/qpsolver
715+
${PROJECT_SOURCE_DIR}/highs/simplex
716+
${PROJECT_SOURCE_DIR}/highs/test_kkt
717+
${PROJECT_SOURCE_DIR}/highs/util)
718718

719719
# explicitly switch on colored output for ninja
720720
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
@@ -728,7 +728,7 @@ if(NOT FAST_BUILD)
728728
# endif()
729729

730730
# Targets
731-
add_subdirectory(src)
731+
add_subdirectory(highs)
732732
add_subdirectory(app)
733733
if(BUILD_TESTING)
734734
enable_testing()

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ For a full list of options, see the [options page](https://ergo-code.github.io/H
187187

188188
## Interfaces
189189

190-
There are HiGHS interfaces for C, C#, FORTRAN, and Python in `HiGHS/src/interfaces`, with example driver files in `HiGHS/examples/`. More on language and modelling interfaces can be found at https://ergo-code.github.io/HiGHS/stable/interfaces/other/.
190+
There are HiGHS interfaces for C, C#, FORTRAN, and Python in `HiGHS/highs/interfaces`, with example driver files in `HiGHS/examples/`. More on language and modelling interfaces can be found at https://ergo-code.github.io/HiGHS/stable/interfaces/other/.
191191

192192
We are happy to give a reasonable level of support via email sent to [email protected].
193193

@@ -213,7 +213,7 @@ The installation can be tested using the small example `HiGHS/examples/call_high
213213
The [Google Colab Example Notebook](https://colab.research.google.com/drive/1JmHF53OYfU-0Sp9bzLw-D2TQyRABSjHb?usp=sharing) also demonstrates how to call `highspy`.
214214

215215
### C
216-
The C API is in `HiGHS/src/interfaces/highs_c_api.h`. It is included in the default build. For more details, check out the documentation website https://ergo-code.github.io/HiGHS/.
216+
The C API is in `HiGHS/highs/interfaces/highs_c_api.h`. It is included in the default build. For more details, check out the documentation website https://ergo-code.github.io/HiGHS/.
217217

218218
### CSharp
219219

@@ -238,7 +238,7 @@ Details for building locally can be found in `nuget/README.md`.
238238

239239
### Fortran
240240

241-
The Fortran API is in `HiGHS/src/interfaces/highs_fortran_api.f90`. It is *not* included in the default build. For more details, check out the documentation website https://ergo-code.github.io/HiGHS/.
241+
The Fortran API is in `HiGHS/highs/interfaces/highs_fortran_api.f90`. It is *not* included in the default build. For more details, check out the documentation website https://ergo-code.github.io/HiGHS/.
242242

243243

244244
## Reference

app/CMakeLists.txt

Lines changed: 32 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,65 @@
11
if(FAST_BUILD)
2-
if (BUILD_CXX)
3-
# create highs binary using library without pic
4-
add_executable(highs-bin)
5-
2+
if (BUILD_CXX_EXE)
63
# Configure the config windows version file
74
if(MSVC)
85
string(REPLACE "." "," PROJECT_RC_VERSION "${PROJECT_VERSION}")
9-
configure_file(${HIGHS_SOURCE_DIR}/version.rc.in
6+
configure_file(${PROJECT_SOURCE_DIR}/version.rc.in
107
"${HIGHS_BINARY_DIR}/version.rc" @ONLY)
118
set(win_version_file ${HIGHS_BINARY_DIR}/version.rc)
129
else()
1310
set(win_version_file)
1411
endif()
1512

13+
add_executable(highs-bin)
1614
target_sources(highs-bin PRIVATE RunHighs.cpp HighsRuntimeOptions.h ${win_version_file})
1715

1816
target_include_directories(highs-bin PRIVATE
19-
$<BUILD_INTERFACE:${HIGHS_SOURCE_DIR}/app>
17+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/app>
2018
)
2119

20+
set_target_properties(highs-bin PROPERTIES POSITION_INDEPENDENT_CODE ON)
21+
2222
if(UNIX)
2323
target_compile_options(highs-bin PUBLIC "-Wno-unused-variable")
2424
target_compile_options(highs-bin PUBLIC "-Wno-unused-const-variable")
2525
endif()
2626

27-
set_target_properties(highs-bin
28-
PROPERTIES OUTPUT_NAME highs)
27+
set_target_properties(highs-bin PROPERTIES OUTPUT_NAME highs)
28+
29+
target_compile_features(highs-bin PRIVATE cxx_std_11)
30+
target_link_libraries(highs-bin PRIVATE ${PROJECT_NAMESPACE}::highs)
2931

30-
target_link_libraries(highs-bin highs)
32+
include(GNUInstallDirs)
3133

3234
if(APPLE)
3335
set_target_properties(highs-bin PROPERTIES INSTALL_RPATH
3436
"@loader_path/../${CMAKE_INSTALL_LIBDIR};@loader_path")
3537
elseif (UNIX)
3638
set_target_properties(highs-bin PROPERTIES INSTALL_RPATH
3739
"$ORIGIN:$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
40+
41+
# cmake_path is 3.20, leave for later.
42+
# cmake_path(RELATIVE_PATH CMAKE_INSTALL_FULL_LIBDIR
43+
# BASE_DIRECTORY ${CMAKE_INSTALL_FULL_BINDIR}
44+
# OUTPUT_VARIABLE libdir_relative_path)
45+
# set_target_properties(highs-bin PROPERTIES INSTALL_RPATH
46+
# "$ORIGIN/${libdir_relative_path}")
3847
endif()
3948

4049
# install the binary
41-
install(TARGETS highs-bin EXPORT highs-targets
42-
RUNTIME)
50+
install(TARGETS highs-bin
51+
EXPORT highs-targets
52+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
53+
54+
if(BUILD_TESTING)
55+
if (APPLE)
56+
set(CMAKE_INSTALL_RPATH
57+
"@loader_path/../${CMAKE_INSTALL_LIBDIR};@loader_path")
58+
elseif (UNIX)
59+
set(CMAKE_INSTALL_RPATH "$ORIGIN/../${CMAKE_INSTALL_LIBDIR}:$ORIGIN:$ORIGIN/../lib:$ORIGIN")
60+
endif ()
61+
endif()
62+
4363
endif()
4464
else()
4565
# create highs binary using library without pic
@@ -54,9 +74,8 @@ else()
5474

5575
target_link_libraries(highs libhighs)
5676

57-
5877
target_include_directories(highs PRIVATE
59-
$<BUILD_INTERFACE:${HIGHS_SOURCE_DIR}/app>
78+
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/app>
6079
)
6180

6281
# install the binary

build_webdemo.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# This will create the file `build_webdemo/bin/highs.html`. For fast edit
1515
# iterations run
1616

17-
# find src app | entr -rs 'make -C build_webdemo highs; echo'
17+
# find highs app | entr -rs 'make -C build_webdemo highs; echo'
1818

1919
# This will rebuild `highs.html` every time a source file is modified (e.g.
2020
# from Visual Studio Code).

0 commit comments

Comments
 (0)