Skip to content

Commit

Permalink
fix add_flag() to correctly add flags to C++ files
Browse files Browse the repository at this point in the history
- fixes luxonis#68
  • Loading branch information
diablodale committed May 30, 2023
1 parent e99a13f commit 147d61a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
# With additions of Luxonis

cmake_minimum_required(VERSION 3.2)
cmake_minimum_required(VERSION 3.3)

include("cmake/HunterGate.cmake")
HunterGate(
Expand Down Expand Up @@ -152,6 +152,7 @@ else()
endif()

# Add flags
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_default_flags(${TARGET_NAME})

# Check if pthread_getname_np exists
Expand Down
6 changes: 6 additions & 0 deletions cmake/Flags.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
## setup compilation flags
# conditionally applies flag. If flag is supported by current compiler, it will be added to compile options.
include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)
function(add_flag target flag)
check_c_compiler_flag(${flag} FLAG_${flag})
if (FLAG_${flag} EQUAL 1)
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:C>:${flag}>)
endif ()
check_cxx_compiler_flag(${flag} FLAGXX_${flag})
if (FLAGXX_${flag} EQUAL 1)
target_compile_options(${target} PRIVATE $<$<COMPILE_LANGUAGE:CXX>:${flag}>)
endif ()
endfunction()

# only works for C source files
function(add_flag_source source flag)
check_c_compiler_flag(${flag} FLAG_${flag})
if (FLAG_${flag} EQUAL 1)
Expand Down
4 changes: 2 additions & 2 deletions src/pc/PlatformDeviceSearchDynamic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,9 @@ xLinkPlatformErrorCode_t XLinkPlatformFindDevicesDynamic(const deviceDesc_t in_d
{
deviceDesc_t* devices = out_foundDevices;
int write_index = 0;
for(int i = 0; i < *out_amountOfFoundDevices; i++){
for(int i = 0, amountBound = static_cast<int>(*out_amountOfFoundDevices); i < amountBound; ++i){
bool duplicate = false;
for(int j = i - 1; j >= 0; j--){
for(int j = i - 1; j >= 0; --j){
// Check if duplicate
if(devices[i].protocol == devices[j].protocol && strcmp(devices[i].name, devices[j].name) == 0 && strcmp(devices[i].mxid, devices[j].mxid) == 0){
duplicate = true;
Expand Down

0 comments on commit 147d61a

Please sign in to comment.