Skip to content

Commit efdd433

Browse files
authored
Merge pull request #2436 from jschueller/unity
CMake: Add support for UNITY_BUILD
2 parents 4aeaf39 + 964de46 commit efdd433

File tree

6 files changed

+18
-3
lines changed

6 files changed

+18
-3
lines changed

.github/workflows/build-fast.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
- name: Configure CMake
1919
shell: bash
2020
working-directory: ${{runner.workspace}}/build
21-
run: cmake $GITHUB_WORKSPACE -DFAST_BUILD=ON -DCMAKE_BUILD_TYPE=RELEASE
21+
run: cmake $GITHUB_WORKSPACE -DFAST_BUILD=ON -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_UNITY_BUILD=ON
2222

2323
- name: Build
2424
working-directory: ${{runner.workspace}}/build
@@ -45,7 +45,7 @@ jobs:
4545
- name: Configure CMake
4646
shell: bash
4747
working-directory: ${{runner.workspace}}/build
48-
run: cmake $GITHUB_WORKSPACE -DFAST_BUILD=ON -DCMAKE_BUILD_TYPE=DEBUG
48+
run: cmake $GITHUB_WORKSPACE -DFAST_BUILD=ON -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_UNITY_BUILD=ON
4949

5050
- name: Build
5151
working-directory: ${{runner.workspace}}/build

app/CMakeLists.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ if(FAST_BUILD)
2525
endif()
2626

2727
set_target_properties(highs-bin PROPERTIES OUTPUT_NAME highs)
28+
set_target_properties(highs-bin PROPERTIES UNITY_BUILD OFF)
2829

2930
target_compile_features(highs-bin PRIVATE cxx_std_11)
3031
target_link_libraries(highs-bin PRIVATE ${PROJECT_NAMESPACE}::highs)
@@ -78,6 +79,8 @@ else()
7879
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/app>
7980
)
8081

82+
set_target_properties(highs PROPERTIES UNITY_BUILD OFF)
83+
8184
# install the binary
8285
install(TARGETS highs EXPORT highs-targets
8386
RUNTIME)
@@ -87,4 +90,4 @@ endif()
8790
if(EMSCRIPTEN AND EMSCRIPTEN_HTML)
8891
set(CMAKE_EXECUTABLE_SUFFIX ".html")
8992
set_target_properties(highs PROPERTIES LINK_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/highs_webdemo_shell.html)
90-
endif()
93+
endif()

check/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ if ((NOT FAST_BUILD OR ALL_TESTS) AND NOT (BUILD_EXTRA_UNIT_ONLY))
106106

107107
add_executable(unit_tests ${TEST_SOURCES})
108108

109+
set_target_properties(unit_tests PROPERTIES UNITY_BUILD OFF)
110+
109111
if (UNIX)
110112
target_compile_options(unit_tests PRIVATE "-Wno-unused-variable")
111113
target_compile_options(unit_tests PRIVATE "-Wno-unused-const-variable")

cmake/cpp-highs.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ function(highs_cxx_test FILE_NAME)
151151

152152
target_compile_features(${TEST_NAME} PRIVATE cxx_std_11)
153153
target_link_libraries(${TEST_NAME} PRIVATE ${PROJECT_NAMESPACE}::highs)
154+
set_target_properties(${TEST_NAME} PROPERTIES UNITY_BUILD OFF)
154155

155156
# include(GNUInstallDirs)
156157
# if(APPLE)
@@ -197,6 +198,7 @@ function(highs_c_test FILE_NAME)
197198

198199
target_compile_features(${TEST_NAME} PRIVATE cxx_std_11)
199200
target_link_libraries(${TEST_NAME} PRIVATE ${PROJECT_NAMESPACE}::highs)
201+
set_target_properties(${TEST_NAME} PROPERTIES UNITY_BUILD OFF)
200202

201203
# include(GNUInstallDirs)
202204
# if(APPLE)

cmake/sources.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,9 @@ set(ipx_headers
176176
ipm/ipx/timer.h
177177
ipm/ipx/utils.h)
178178

179+
# redefinition of 'kHighsInf'
180+
set_source_files_properties (../extern/filereaderlp/reader.cpp PROPERTIES SKIP_UNITY_BUILD_INCLUSION ON)
181+
179182
set(highs_sources
180183
../extern/filereaderlp/reader.cpp
181184
interfaces/highs_c_api.cpp

highs/ipm/basiclu/lu_list.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
#ifndef _LU_LIST_H
2+
#define _LU_LIST_H
3+
14
/*
25
* lu_list.h
36
*
@@ -166,3 +169,5 @@ static inline void lu_list_swap(
166169
blink[e2next] = e1;
167170
}
168171
}
172+
173+
#endif

0 commit comments

Comments
 (0)