CMake: handle Client's options
This commit is contained in:
parent
4467fcd52c
commit
93adfdc55c
|
@ -9,6 +9,10 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
|
|||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||
|
||||
# Path for the generated header files
|
||||
set(GENERATED_INCLUDE "${PROJECT_BINARY_DIR}/include")
|
||||
include_directories("${GENERATED_INCLUDE}")
|
||||
|
||||
|
||||
### Libraries ###
|
||||
|
||||
|
|
2
TODO.t2t
2
TODO.t2t
|
@ -61,8 +61,6 @@ Work to do in OwlPS
|
|||
- compilation flags
|
||||
- installation targets
|
||||
- static targets
|
||||
- Client: handle ENABLE_RECEIVE_POSITION and link to
|
||||
libowlps-resultreader when activated
|
||||
- Listener: handle options (USE_CONFIG_FILE, USE_PTHREAD,
|
||||
ENABLE_KEEP_MONITOR@
|
||||
- compile Positioner
|
||||
|
|
|
@ -1,10 +1,30 @@
|
|||
### Options ###
|
||||
|
||||
option(OWLPS_CLIENT_RECEIVES_POSITION
|
||||
"Enable -l (receive the computed position from the Positioner)"
|
||||
off)
|
||||
|
||||
configure_file(
|
||||
owlps-client-config.h.in
|
||||
"${GENERATED_INCLUDE}/owlps-client-config.h")
|
||||
|
||||
|
||||
### Targets ###
|
||||
|
||||
add_executable(owlps-client owlps-client.c)
|
||||
target_link_libraries(owlps-client
|
||||
libowlps.so
|
||||
libowlps-client.so)
|
||||
if (OWLPS_CLIENT_RECEIVES_POSITION)
|
||||
target_link_libraries(owlps-client
|
||||
libowlps-resultreader.so)
|
||||
endif()
|
||||
|
||||
add_executable(owlps-client.semistatic owlps-client.c)
|
||||
target_link_libraries(owlps-client.semistatic
|
||||
libowlps.a
|
||||
libowlps-client.a)
|
||||
if (OWLPS_CLIENT_RECEIVES_POSITION)
|
||||
target_link_libraries(owlps-client.semistatic
|
||||
libowlps-resultreader.a)
|
||||
endif()
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
/*
|
||||
* This file is part of the Owl Positioning System (OwlPS).
|
||||
*
|
||||
* Copyright © 2013 Matteo Cypriani <mcy@lm7.fr>
|
||||
*
|
||||
***********************************************************************
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL:
|
||||
* http://www.cecill.info
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided
|
||||
* only with a limited warranty and the software's authors, the holder
|
||||
* of the economic rights, and the successive licensors have only
|
||||
* limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks
|
||||
* associated with loading, using, modifying and/or developing or
|
||||
* reproducing the software by the user in light of its specific status
|
||||
* of free software, that may mean that it is complicated to manipulate,
|
||||
* and that also therefore means that it is reserved for developers and
|
||||
* experienced professionals having in-depth computer knowledge. Users
|
||||
* are therefore encouraged to load and test the software's suitability
|
||||
* as regards their requirements in conditions enabling the security of
|
||||
* their systems and/or data to be ensured and, more generally, to use
|
||||
* and operate it in the same conditions as regards security.
|
||||
*
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
***********************************************************************
|
||||
*
|
||||
* This is the configuration header file for OwlPS Client.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _OWLPS_CLIENT_CONFIG_H_
|
||||
#define _OWLPS_CLIENT_CONFIG_H_
|
||||
|
||||
#cmakedefine OWLPS_CLIENT_RECEIVES_POSITION
|
||||
|
||||
#endif // _OWLPS_CLIENT_CONFIG_H_
|
|
@ -42,11 +42,13 @@
|
|||
*/
|
||||
|
||||
|
||||
#include <owlps-client-config.h>
|
||||
|
||||
#include <owlps-client.h>
|
||||
|
||||
#ifdef ENABLE_RECEIVE_POSITION
|
||||
#ifdef OWLPS_CLIENT_RECEIVES_POSITION
|
||||
# include <owlps-resultreader.h>
|
||||
#endif // ENABLE_RECEIVE_POSITION
|
||||
#endif // OWLPS_CLIENT_RECEIVES_POSITION
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -91,9 +93,9 @@ void make_packet(void) ;
|
|||
void add_padding(void) ;
|
||||
uint_fast16_t initialise_common_fields(uint_fast8_t packet_type) ;
|
||||
uint_fast16_t initialise_calibration_fields(uint_fast16_t offset) ;
|
||||
#ifdef ENABLE_RECEIVE_POSITION
|
||||
#ifdef OWLPS_CLIENT_RECEIVES_POSITION
|
||||
int receive_position(void) ;
|
||||
#endif // ENABLE_RECEIVE_POSITION
|
||||
#endif // OWLPS_CLIENT_RECEIVES_POSITION
|
||||
void print_usage(void) ;
|
||||
void print_version(void) ;
|
||||
|
||||
|
@ -185,10 +187,10 @@ int main(int argc, char *argv[])
|
|||
|
||||
close(sockfd) ;
|
||||
|
||||
#ifdef ENABLE_RECEIVE_POSITION
|
||||
#ifdef OWLPS_CLIENT_RECEIVES_POSITION
|
||||
if (options.listening_port > 0)
|
||||
ret = receive_position() ;
|
||||
#endif // ENABLE_RECEIVE_POSITION
|
||||
#endif // OWLPS_CLIENT_RECEIVES_POSITION
|
||||
|
||||
return ret ;
|
||||
}
|
||||
|
@ -252,7 +254,7 @@ void parse_main_options(int argc, char **argv)
|
|||
strncpy(options.dest_ip, optarg, INET_ADDRSTRLEN) ;
|
||||
break ;
|
||||
case 'l' :
|
||||
#ifdef ENABLE_RECEIVE_POSITION
|
||||
#ifdef OWLPS_CLIENT_RECEIVES_POSITION
|
||||
/* Facultative getopt options do not handle separated values
|
||||
* (like -l <port>), so we have to test separately.
|
||||
*/
|
||||
|
@ -273,11 +275,11 @@ void parse_main_options(int argc, char **argv)
|
|||
++optind ;
|
||||
}
|
||||
}
|
||||
#else // ENABLE_RECEIVE_POSITION
|
||||
#else // OWLPS_CLIENT_RECEIVES_POSITION
|
||||
fprintf(stderr, "Warning! The program was compiled without"
|
||||
" enabling the -l option (receive the position from"
|
||||
" the positioning server).\n") ;
|
||||
#endif // ENABLE_RECEIVE_POSITION
|
||||
#endif // OWLPS_CLIENT_RECEIVES_POSITION
|
||||
break ;
|
||||
case 'n' :
|
||||
options.nb_pkt = strtoul(optarg, NULL, 0) ;
|
||||
|
@ -649,7 +651,7 @@ uint_fast16_t initialise_calibration_fields(uint_fast16_t offset)
|
|||
|
||||
|
||||
|
||||
#ifdef ENABLE_RECEIVE_POSITION
|
||||
#ifdef OWLPS_CLIENT_RECEIVES_POSITION
|
||||
/*
|
||||
* Receives a position computed by the infrastructure.
|
||||
* Note that it is currently not guaranteed that the received result
|
||||
|
@ -676,7 +678,7 @@ int receive_position()
|
|||
|
||||
return 0 ;
|
||||
}
|
||||
#endif // ENABLE_RECEIVE_POSITION
|
||||
#endif // OWLPS_CLIENT_RECEIVES_POSITION
|
||||
|
||||
|
||||
|
||||
|
@ -741,7 +743,7 @@ void print_usage()
|
|||
" The\n\t\t\toptional argument <port> allows to specify the"
|
||||
" listening\n\t\t\tport (default: %d). Available only if the"
|
||||
" program was\n\t\t\tcompiled with the compilation-time option"
|
||||
"\n\t\t\tENABLE_RECEIVE_POSITION.\n",
|
||||
"\n\t\t\tOWLPS_CLIENT_RECEIVES_POSITION.\n",
|
||||
program_name,
|
||||
program_name,
|
||||
OWL_DEFAULT_REQUEST_PORT,
|
||||
|
@ -768,10 +770,10 @@ void print_version()
|
|||
"unknown version"
|
||||
#endif // OWLPS_VERSION
|
||||
,
|
||||
#ifdef ENABLE_RECEIVE_POSITION
|
||||
#ifdef OWLPS_CLIENT_RECEIVES_POSITION
|
||||
"YES"
|
||||
#else // ENABLE_RECEIVE_POSITION
|
||||
#else // OWLPS_CLIENT_RECEIVES_POSITION
|
||||
"NO"
|
||||
#endif // ENABLE_RECEIVE_POSITION
|
||||
#endif // OWLPS_CLIENT_RECEIVES_POSITION
|
||||
) ;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue