Skip to content

Commit c42d2ce

Browse files
CMake cleanup
* Change option `WERROR` to `RTOSC_WERROR` (for use in other projects) * Fix using the current source/binary paths when compiling rtosc inside of other projects * Fix warnings about VLAs (that occur with Clang) * Fix warnings in code (that occur with GCC new Arch Linux)
1 parent c33ad42 commit c42d2ce

File tree

5 files changed

+22
-22
lines changed

5 files changed

+22
-22
lines changed

.github/workflows/ccpp.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ jobs:
1717
config: "cmake
1818
-B build
1919
-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake
20-
-DWERROR=1
20+
-DRTOSC_WERROR=1
2121
-DCMAKE_BUILD_TYPE=Debug
2222
",
2323
build: "cmake --build build --config Debug",
@@ -30,7 +30,7 @@ jobs:
3030
enabled: 1,
3131
os: ubuntu-latest,
3232
deps: "sudo apt-get install liblo-dev",
33-
config: "cd build && cmake -DWERROR=1 ..",
33+
config: "cd build && cmake -DRTOSC_WERROR=1 ..",
3434
build: "cd build && make",
3535
test: "cd build && ctest --output-on-failure"
3636
}
@@ -41,7 +41,7 @@ jobs:
4141
deps: "sudo apt-get install liblo-dev",
4242
config: "cd build &&
4343
cmake
44-
-DWERROR=1
44+
-DRTOSC_WERROR=1
4545
-DCMAKE_C_COMPILER=clang
4646
-DCMAKE_CXX_COMPILER=clang++
4747
-DCMAKE_SHARED_LINKER_FLAGS='-fuse-ld=lld'
@@ -55,7 +55,7 @@ jobs:
5555
enabled: 1,
5656
os: macos-latest,
5757
deps: "brew install liblo",
58-
config: "cd build && cmake -DWERROR=1 ..",
58+
config: "cd build && cmake -DRTOSC_WERROR=1 ..",
5959
build: "cd build && make",
6060
test: "cd build && ctest --output-on-failure"
6161
}

CMakeLists.txt

+11-11
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ if(NOT CMAKE_BUILD_TYPE)
5454
endif()
5555
option(RTOSC_INCLUDE_WHAT_YOU_USE "Check for useless includes" OFF)
5656
mark_as_advanced(FORCE RTOSC_INCLUDE_WHAT_YOU_USE)
57-
option(WERROR "Compile with warnings being treated as errors" OFF)
57+
option(RTOSC_WERROR "Compile with warnings being treated as errors" OFF)
5858

5959
set(BUILD_RTOSC_EXAMPLES FALSE CACHE BOOL
6060
"Build RTOSC Example Programs")
@@ -70,7 +70,7 @@ set(MSVC_CNV_WARN "/wd4244 /wd4267 /wd4305")
7070
#Ignore the whole non-portable string*_s function recommendations
7171
set(MSVC_SAFE_WARN "/wd4996")
7272

73-
if(WERROR)
73+
if(RTOSC_WERROR)
7474
if(MSVC)
7575
set(WERROR_FLAG "/WX")
7676
else()
@@ -83,7 +83,7 @@ if(MSVC)
8383
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MSVC_CNV_WARN} ${MSVC_SAFE_WARN} ${WERROR_FLAG}")
8484
else()
8585
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra ${WERROR_FLAG}")
86-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra ${WERROR_FLAG}")
86+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-vla-cxx-extension ${WERROR_FLAG}")
8787
endif(MSVC)
8888

8989

@@ -239,23 +239,23 @@ maketestcpp(test-automation)
239239
if(LIBLO_FOUND)
240240
add_library(lo-server test/liblo-server.cpp)
241241
target_include_directories(lo-server PRIVATE ${LIBLO_INCLUDE_DIRS})
242-
target_include_directories(lo-server PRIVATE ${CMAKE_SOURCE_DIR}/include)
242+
target_include_directories(lo-server PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include)
243243
target_link_libraries(lo-server PRIVATE ${RTOSC_LIBLO_LIBRARIES})
244244
target_link_directories(performance PRIVATE ${LIBLO_LIBRARY_DIRS})
245245
set(RTOSC_TEST_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/test CACHE INTERNAL "")
246246
set(RTOSC_TEST_LIB_DIR ${CMAKE_CURRENT_BINARY_DIR} CACHE INTERNAL "")
247247
endif()
248248
if(LIBLO_FOUND AND RUBY_FOUND)
249249
add_executable(port-checker test/port-checker-main.cpp)
250-
target_include_directories(port-checker PRIVATE ${LIBLO_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)
250+
target_include_directories(port-checker PRIVATE ${LIBLO_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
251251
target_link_libraries(port-checker PRIVATE lo-server rtosc-cpp rtosc ${RTOSC_LIBLO_LIBRARIES})
252252
target_link_directories(port-checker PRIVATE ${LIBLO_LIBRARY_DIRS})
253253
add_executable(port-checker-tester test/port-checker-tester.cpp)
254-
target_include_directories(port-checker-tester PRIVATE ${LIBLO_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)
254+
target_include_directories(port-checker-tester PRIVATE ${LIBLO_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
255255
target_link_libraries(port-checker-tester PRIVATE lo-server rtosc-cpp rtosc ${RTOSC_LIBLO_LIBRARIES})
256256
target_link_directories(port-checker-tester PRIVATE ${LIBLO_LIBRARY_DIRS})
257257
add_executable(port-checker-testapp test/port-checker-testapp.cpp)
258-
target_include_directories(port-checker-testapp PRIVATE ${LIBLO_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/include)
258+
target_include_directories(port-checker-testapp PRIVATE ${LIBLO_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/include)
259259
target_link_libraries(port-checker-testapp PRIVATE rtosc-cpp rtosc ${RTOSC_LIBLO_LIBRARIES})
260260
target_link_directories(port-checker-testapp PRIVATE ${LIBLO_LIBRARY_DIRS})
261261
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/test/test-port-checker.rb
@@ -282,12 +282,12 @@ endif()
282282
if(CMAKE_SYSTEM_NAME MATCHES "Linux" AND NOT DEFINED RTOSC_NO_INSTALL)
283283
if(PKG_CONFIG_FOUND)
284284
configure_file(librtosc.pc.cmake
285-
${CMAKE_BINARY_DIR}/librtosc.pc @ONLY)
286-
install(FILES ${CMAKE_BINARY_DIR}/librtosc.pc
285+
${CMAKE_CURRENT_BINARY_DIR}/librtosc.pc @ONLY)
286+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/librtosc.pc
287287
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/")
288288
configure_file(librtosc-cpp.pc.cmake
289-
${CMAKE_BINARY_DIR}/librtosc-cpp.pc @ONLY)
290-
install(FILES ${CMAKE_BINARY_DIR}/librtosc-cpp.pc
289+
${CMAKE_CURRENT_BINARY_DIR}/librtosc-cpp.pc @ONLY)
290+
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/librtosc-cpp.pc
291291
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/")
292292
endif()
293293
install(FILES include/rtosc/rtosc.h

example/complex/Fl_Osc_Tree.H

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,15 @@ class Fl_Osc_Tree:Fl_Tree
7171
t->sprout(path);
7272
} else {
7373
char tmpa[1024];
74-
char tmpb[1024];
74+
char tmpb[1040];
7575
strncpy(tmpa, path.c_str(), 1024-1);
7676
char *pound = strchr(tmpa, '#');
7777
int N = atoi(pound+1);
7878
*pound = 0;
7979
char terminal = subnodes ? '/' : '\0';
8080

8181
for(int i = 0; i < N; ++i) {
82-
snprintf(tmpb, 1024, "%s%d%c",
82+
snprintf(tmpb, sizeof(tmpb), "%s%d%c",
8383
tmpa, i, terminal);
8484
t->sprout(tmpb);
8585
}

example/complex/Fl_Osc_View.H

+4-4
Original file line numberDiff line numberDiff line change
@@ -174,10 +174,10 @@ class Fl_Osc_View: public Fl_Double_Window
174174
rtosc::walk_ports(p, buffer, sizeof(buffer), table,
175175
[](const rtosc::Port *p,
176176
const char *name,
177-
const char *_,
178-
const rtosc::Ports &__,
177+
const char *,
178+
const rtosc::Ports &,
179179
void*t,
180-
void*runtime) {
180+
void*) {
181181
PortTable *table = (PortTable*)t;
182182

183183
port_view tmp = {name, *p, -1, -1};
@@ -212,7 +212,7 @@ class Fl_Osc_View: public Fl_Double_Window
212212
Fl_Osc_Interface *osc;
213213
};
214214

215-
static void Delete_CB(Fl_Widget *w, void *v_)
215+
static void Delete_CB(Fl_Widget *, void *v_)
216216
{
217217
Fl_Osc_View &v = *(Fl_Osc_View*)v_;
218218
int row_top, col_left, row_bot, col_right;

example/complex/window.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ struct Fl_Center_Knob : public Fl_Osc_Dial
8787
template<typename T>
8888
struct Fl_Square : public Fl_Osc_Group
8989
{
90-
Fl_Square<T>(int x, int y, int w, int h, int _pad, const Port *port)
90+
Fl_Square(int x, int y, int w, int h, int _pad, const Port *port)
9191
:Fl_Osc_Group(x,y,w,h,NULL), pad(_pad)
9292
{
9393
const int l = min(max(w-2*pad,0),max(h-2*pad,0));

0 commit comments

Comments
 (0)