fix: configure over cmake options
This commit is contained in:
		
							parent
							
								
									6e3b1d52a4
								
							
						
					
					
						commit
						11f1a79d6a
					
				
					 4 changed files with 24 additions and 13 deletions
				
			
		| 
						 | 
				
			
			@ -3,7 +3,8 @@ project(controller)
 | 
			
		|||
 | 
			
		||||
add_executable(controller main.c)
 | 
			
		||||
 | 
			
		||||
option(WIRING_PI_DEBUG "Use WiringPi Debugging Tool" OFF)
 | 
			
		||||
option(WIRING_PI_DEBUG "Use WiringPi Debugging Tool (0=off, 1=silent, 2=LOG_DEBUG) (0)" OFF)
 | 
			
		||||
option(LOG_LEVEL "Set logging level (5=trace, 4=debug, 3=info, 2=warn, 1=error, 0=fatal) (3)" OFF)
 | 
			
		||||
 | 
			
		||||
SET(CMAKE_C_FLAGS "-Wall -Wextra -lwiringPi -lwiringPiDev -luuid -llmdb -g")
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -11,9 +12,18 @@ string(LENGTH "${CMAKE_SOURCE_DIR}/" SOURCE_PATH_SIZE)
 | 
			
		|||
add_definitions("-DSOURCE_PATH_SIZE=${SOURCE_PATH_SIZE}")
 | 
			
		||||
 | 
			
		||||
if(WIRING_PI_DEBUG)
 | 
			
		||||
    message("Using wiringPi debug calls")
 | 
			
		||||
    add_compile_definitions("WIRING_PI_DEBUG")
 | 
			
		||||
    if(WIRING_PI_DEBUG GREATER 1)
 | 
			
		||||
        message("Showing wiringPi calls as debug")
 | 
			
		||||
    else(WIRING_PI_DEBUG GREATER 1)
 | 
			
		||||
        message("Ignoring wiringPi calls")
 | 
			
		||||
    endif(WIRING_PI_DEBUG GREATER 1)
 | 
			
		||||
    add_definitions("-DWIRING_PI_DEBUG=${WIRING_PI_DEBUG}")
 | 
			
		||||
endif(WIRING_PI_DEBUG)
 | 
			
		||||
if(LOG_LEVEL)
 | 
			
		||||
    add_definitions("-DLOG_LEVEL=${LOG_LEVEL}")
 | 
			
		||||
else(LOG_LEVEL)
 | 
			
		||||
    add_definitions("-DLOG_LEVEL=3")
 | 
			
		||||
endif(LOG_LEVEL)
 | 
			
		||||
 | 
			
		||||
aux_source_directory(vendor VENDOR_SRC) # vendor first to put their warnings on top
 | 
			
		||||
aux_source_directory(. SRC_DIR)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -29,7 +29,7 @@ handler_discovery(int fd, controller_t *controller)
 | 
			
		|||
        LOG_ERROR("received invalid discovery from %s", inet_ntoa(si_other.sin_addr));
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
    LOG_DEBUG("received discovery from %s for port %d", inet_ntoa(si_other.sin_addr), discovery_answer_port);
 | 
			
		||||
    LOG_INFO("received discovery from %s:%d", inet_ntoa(si_other.sin_addr), discovery_answer_port);
 | 
			
		||||
 | 
			
		||||
    if(discovery_answer_port == 0)
 | 
			
		||||
    {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -23,13 +23,6 @@
 | 
			
		|||
 */
 | 
			
		||||
#define MDB_MAXDBS 8
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Indicates to which level to log
 | 
			
		||||
 *
 | 
			
		||||
 * @see include/log_levels.h
 | 
			
		||||
 */
 | 
			
		||||
#define LOG_LEVEL LOG_LEVEL_DEBUG
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief How many milli seconds to wait until poll timeout in main loop
 | 
			
		||||
 */
 | 
			
		||||
| 
						 | 
				
			
			@ -37,4 +30,8 @@
 | 
			
		|||
 | 
			
		||||
#define PIFACE_GPIO_BASE 200
 | 
			
		||||
 | 
			
		||||
#ifndef LOG_LEVEL
 | 
			
		||||
    #define LOG_LEVEL LOG_LEVEL_INFO
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* CONTROLLER_CONTANTS_H */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -3,9 +3,13 @@
 | 
			
		|||
 | 
			
		||||
#include <logger.h>
 | 
			
		||||
 | 
			
		||||
#define LOG_WIRING_DEBUG(x, ...) LOG_DEBUG(x, ##__VA_ARGS__)
 | 
			
		||||
 | 
			
		||||
#ifdef WIRING_PI_DEBUG
 | 
			
		||||
    #if WIRING_PI_DEBUG > 1
 | 
			
		||||
        #define LOG_WIRING_DEBUG(x, ...) LOG_DEBUG(x, ##__VA_ARGS__)
 | 
			
		||||
    #else
 | 
			
		||||
        #define LOG_WIRING_DEBUG(x, ...)
 | 
			
		||||
    #endif
 | 
			
		||||
 | 
			
		||||
    #define wiringPiSetup() LOG_WIRING_DEBUG("wiringPi wiringPiSetup()")
 | 
			
		||||
    #define wiringPiSetupSys() LOG_WIRING_DEBUG("wiringPi wiringPiSetupSys()")
 | 
			
		||||
    #define pinMode(x,y) LOG_WIRING_DEBUG("wiringPi pinMode(%d, %d)", x, y)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue