Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
182 commits
Select commit Hold shift + click to select a range
3def7aa
Rename the project lightsd
lopter Jan 24, 2015
fd6a68a
Let the timer code restart the discovery on a write error
lopter Jan 24, 2015
7116cb8
Use SO_REUSEADDR on the broadcast socket
lopter Feb 16, 2015
a9c2258
Re-transmit GET_LIGHT_STATUS instead of waiting for the gateway to ti…
lopter Feb 16, 2015
3969b13
Start a TCP/JSON-RPC API
lopter Feb 16, 2015
f93ac5f
Add support for passing JSONRPC params as arrays
lopter Feb 18, 2015
b0a06bb
Fix build warning
lopter Feb 18, 2015
69c1d97
Fix the previous fix on Mac OS
lopter Feb 18, 2015
eb6bdf4
Remove code and reduce discovery time by 2s
lopter Feb 20, 2015
96c9329
Change the license to GPLv3
lopter Mar 8, 2015
88d3bd2
Remove useless file
lopter Mar 8, 2015
8965c84
Forgot to add this unit test earlier
lopter Mar 8, 2015
1dca385
Don't segfault when sending back a JSONRPC error without an id
lopter Mar 8, 2015
657618f
Experiment some retry logic on power_on/power_off
lopter Mar 8, 2015
a8e9311
Do not enqueue multiple GET_LIGHT_STATE for all bulbs on a single gat…
lopter Mar 8, 2015
bc7e618
Fix crash on newline in the jsonrpc code
lopter Mar 8, 2015
716d38b
Add the ability to target a specific device via its address
lopter Mar 8, 2015
568f82d
Re-transmit power_on & power_off via device address
lopter Mar 8, 2015
7fd73c6
Add the transition duration (in ms) argument to set_light_from_hsbk
lopter Mar 8, 2015
6a505de
Backed out changeset c109b3351e99
lopter Mar 14, 2015
ec98bb3
Stop being retarded on includes
lopter Mar 15, 2015
e4add61
Add the set_waveform command
lopter Mar 15, 2015
74c73ab
Log device latency at debug only
lopter Apr 2, 2015
c869f8a
Rename the LIFX header timestamp field to at_time
lopter Apr 2, 2015
2dafe1a
Allow the target argument to be a list
lopter Apr 6, 2015
68552e5
Return responses and errors from lgtd_proto
lopter Apr 11, 2015
e3e108d
Beef-up the test suite by testing the proto module
lopter Apr 12, 2015
fc38d30
Remove useless type size instrospection for suseconds_t
lopter May 9, 2015
310b5e0
Turn lifx_gateway.site into an union with an uint64_t
lopter May 9, 2015
bff30dd
Fix broadcast and multicast (aka tagged) routing to LIFX bulbs
lopter May 9, 2015
7967ea4
Send only one LIFX packet per UDP datagram
lopter May 9, 2015
a70d23a
Handle the LIFX tag labels traffic
lopter May 9, 2015
437d79b
Add the list_tags command
lopter May 9, 2015
5619726
Update README with currently supported features
lopter May 14, 2015
d72595c
Update README and add some build instructions
lopter May 18, 2015
67ccb15
Labels and tags can now be used as targets
lopter May 18, 2015
7dbecc7
Store the tag_id alongside each (tag) site
lopter May 18, 2015
ced9437
Fix a bunch of compilation warnings in RELEASE mode
lopter May 18, 2015
17843d1
Don't log device labels as tags when routing packets
lopter May 19, 2015
b66c720
Set bulb->dirty_at when targeting labels and tags
lopter May 19, 2015
8288393
Cope with older versions of CMake and the glibc
lopter Jul 3, 2015
b2e24a0
Fix build warnings on mips32
lopter Jul 3, 2015
6b22a59
Add the get_light_state command
lopter Jul 3, 2015
efbdba0
Fix 32 bit integer overflow in jsonrpc_float_range_to_uint16
lopter Jul 3, 2015
85a344e
Fix bitshift in test_utils_insert_mock_bulb for big endian systems
lopter Jul 3, 2015
9d7a6c5
Fix things for big endian architectures
lopter Jul 9, 2015
4467da5
Remove the list_tags command
lopter Jul 9, 2015
64520f0
Fix endian conversion in lifx_wire_encode_waveform
lopter Jul 9, 2015
5fdf054
Fix set_waveform on big endian systems
lopter Jul 10, 2015
0ceb8d8
Fix incorrect values returned in get_light_state
lopter Jul 16, 2015
9e44070
Update README with upcoming features and spell functions correctly
lopter Jul 16, 2015
954cf35
Fix build warnings on Mac OS X
lopter Jul 16, 2015
20760d9
Allow duplicate listening address in the command line
lopter Aug 8, 2015
05df13a
Add support for a write-only command pipe for easy scripting
lopter Aug 8, 2015
925adaa
Actual support for daemonization with a nice process name
lopter Aug 8, 2015
5a674c2
UI/Cosmetic fixes
lopter Aug 8, 2015
c2a3605
Add initial support for tag (grouping) and untag (ungrouping)
lopter Aug 8, 2015
be1bb5d
Reword the README a bit
lopter Aug 8, 2015
da9c1bb
Handle intermediate values between POWER_STATE_ON and OFF from the bulbs
lopter Aug 8, 2015
799614c
Handle bulbs with bugged tags bitfields
lopter Aug 8, 2015
c868365
Fix a couple function names
lopter Aug 8, 2015
3bc2951
Ignore my packet captures directory
lopter Aug 8, 2015
c8ad1d8
Remove unused __attribute__((unused))
lopter Aug 8, 2015
72ef826
Pass pkt_info around instead of looking it up twice
lopter Aug 8, 2015
d3f29c4
Relax different timings a bit (until we get auto-retry on everything)
lopter Aug 8, 2015
6171a67
Don't abort on request without an id in debug builds
lopter Aug 8, 2015
4823ad1
Fix tag targeting on big endian platforms
lopter Aug 8, 2015
82e4ff4
Fix an incorrectly checked snprintf return value.
lopter Aug 9, 2015
b85fbcb
Add the toggle command: turn on a bulb if it's off and vice-versa
lopter Aug 9, 2015
4e73596
Document tag/untag and update known issues
lopter Aug 9, 2015
ade73dc
Properly do type punning on float endian conversion functions
lopter Aug 9, 2015
02c3ca5
Fix a couple tests and some warning on mips32
lopter Aug 9, 2015
f84f5e3
Return the bulb address in get_light_state if the bulb label is empty
lopter Aug 9, 2015
f81b989
Use jq when available in lightsc.sh
lopter Aug 15, 2015
e1c7f90
Fix IPv4 address formatting
lopter Aug 15, 2015
a29669b
Fix infinite loop in the command pipe read callback
lopter Aug 15, 2015
9c0fad2
Correctly convert LIFX addresses to ASCII
lopter Aug 23, 2015
4b19bed
Bump the device timeout to 2.5x device force refresh
lopter Aug 23, 2015
75e2e32
Ignore SIGPIPE
lopter Aug 23, 2015
349773d
Add an interface to start and stop standalone timers
lopter Aug 24, 2015
4cfa13d
Speed-up bulbs discovery
lopter Aug 24, 2015
f9f37d1
Expose the bulb address, model and firmware version in get_light_state
lopter Aug 24, 2015
598e223
Add all waveform types and the adjust_brightness command in lightsc.py
lopter Aug 24, 2015
5227005
Rename PULSE to SQUARE and document set_waveform's skew_ratio argument
lopter Aug 24, 2015
27da322
Feed the clang compilation database to YouCompleteMe
lopter Aug 24, 2015
1254ed5
Add the set_label command
lopter Aug 24, 2015
096acff
Properly handle 32 chars long LIFX labels in get_light_state
lopter Aug 24, 2015
8506649
Do not stop at the first match when targeting a label
lopter Aug 24, 2015
53cef92
Add missing unit-tests on tag/untag
lopter Aug 24, 2015
210a362
Log something before forking into the background
lopter Aug 24, 2015
69975ba
set_label didn't totally make it in the README, fix that.
lopter Aug 24, 2015
1f8c8f9
Properly walk over json objects and arrays
lopter Aug 24, 2015
16513e9
Stop the LIFX watchdog at cleanup
lopter Aug 24, 2015
6706bad
Add support for JSON-RPC batch requests/responses
lopter Aug 31, 2015
7b38573
Rewrite lightsc.py to be simpler to use, more re-usable & BSD licensed
lopter Aug 31, 2015
6730a7a
Add batch support in lightsc.sh (somewhat)
lopter Aug 31, 2015
48b9554
Add support for the ambient light sensor (left unimplemented by LIFX)
lopter Aug 31, 2015
ec9b07a
Make the pipe/socket read loops fully resilient against incomplete json
lopter Aug 31, 2015
cac8fff
params are optional in JSON-RPC don't crash if they are missing
lopter Aug 31, 2015
c2f40a8
Add packet type definitions for GET_LOCATION/GROUP STATE_LOCATION/GROUP
lopter Aug 31, 2015
29ac6d4
Set the verbosity to INFO by default
lopter Aug 31, 2015
72c4ed3
Use a function to get a gateway's latency
lopter Aug 31, 2015
f5763d1
Run lightsd in the foreground by default and clarify the README
lopter Aug 31, 2015
69a590d
Release prep
lopter Sep 3, 2015
14aca2f
Added tag 0.9.0 for changeset 38014f13f04d
lopter Sep 3, 2015
89cf3f8
Fix in-place builds
lopter Sep 4, 2015
046d73f
Added tag 0.9.1 for changeset 21d438d34e21
lopter Sep 4, 2015
b1edc2d
Rename --install-prefix into --prefix
lopter Sep 13, 2015
e268b00
Add support for unix sockets with the -s option (--socket)
lopter Sep 13, 2015
2aed671
Properly handle JSON-RPC notifications
lopter Sep 13, 2015
fcd0f66
Stop using a global struct in watchdog.c
lopter Sep 13, 2015
01ea64c
Incrementally switch from active discovery to passive discovery
lopter Sep 13, 2015
d6488ee
Handle arbitrary large JSON-RPC request up to 4KiB
lopter Sep 13, 2015
aad31d5
Import setproctitle from libbsd 0.7.0
lopter Sep 13, 2015
e15f263
Add a systemd unit file and -u/-g options to drop privileges
lopter Sep 13, 2015
05478a1
Handle an existing non-fifo file with -c option more gracefully
lopter Sep 13, 2015
01cc165
Do a much better job at keeping in-sync with the bulb
lopter Sep 13, 2015
87a0eeb
Create parent directories for pipes and unix sockets
lopter Sep 13, 2015
3088bb7
Rename the LIFX watchdog module to discovery
lopter Sep 13, 2015
f32cdad
Add the --rundir option so we can easily launch lightsc.py
lopter Sep 13, 2015
8237518
Added tag 0.9.2 for changeset 3a4befe8819e
lopter Sep 14, 2015
4163e18
Fix command pipe support & cleanup of pipes/sockets
lopter Sep 14, 2015
8ebf3aa
Added tag 0.9.3 for changeset 8a41f4cfee7e
lopter Sep 14, 2015
e5dc562
Fix how the program name is displayed in the help message
lopter Sep 16, 2015
98b6d05
Fix command pipe handling in lightsc.sh and add an alert example
lopter Sep 16, 2015
c1e257d
Fix the LIFX gateway timeout detection
lopter Sep 16, 2015
3936c4e
Write installation and usage instructions, rehaul README
lopter Sep 16, 2015
68083fc
Added tag 0.9.4 for changeset 4ef909311670
lopter Sep 16, 2015
ec85a29
Link the documentation from the README
lopter Sep 16, 2015
e0c06a3
Link back to the repository from the documentation
lopter Sep 16, 2015
84e600c
Adjust the documentation a little bit
lopter Sep 17, 2015
44e5aa3
Added tag 1.0.0 for changeset 31b8ef65d3d2
lopter Sep 17, 2015
5ead6ee
Document the -u option for lightsc.py and fix some formatting
lopter Sep 17, 2015
aac2c46
Cope with versions of CMake older than 2.8.11
lopter Sep 19, 2015
f473241
Actually fix set_waveform on big endian architectures
lopter Sep 19, 2015
e06efc1
Document the unix:// scheme for lightsc.py's -u option
lopter Sep 19, 2015
d351352
Properly initialize the process title even when no bulbs are discovered
lopter Sep 19, 2015
78f9ecb
Fix build on OpenBSD 5.7
lopter Sep 19, 2015
0e7327d
Add product id for the 230V version of the LIFX White 800
lopter Sep 19, 2015
c27d036
Add a changelog section in the documentation
lopter Sep 19, 2015
50e923d
Added tag 1.0.1 for changeset 1f7c28381493
lopter Sep 19, 2015
ada9b0c
Fix a small typo in README.rst.
sas Oct 18, 2015
03e6c60
Merge pull request #6 from sas/patch-1
lopter Oct 18, 2015
1c80bc9
Fix missing null byte for progname
Magicking Nov 8, 2015
8ad7007
Add the --syslog (-S), --syslog-facility (-F), --syslog-ident (-I) op…
lopter Nov 8, 2015
3097bde
Lookup for a socket in a build directory in lightsc.py
lopter Nov 8, 2015
17cc4d3
Stop documenting the -f option
lopter Nov 8, 2015
950b53a
Fix lintian warning with lightsc.sh
lopter Nov 8, 2015
d601bfa
Replace `b64encode' by `openssl base64' in lightsc.sh
lopter Nov 8, 2015
720a661
Increase lightsc.py's receive buffer size to 64KiB
lopter Nov 8, 2015
84fd035
Update LIFX product ids and models
lopter Nov 8, 2015
5f33cb4
Add build instructions for Debian like systems
lopter Nov 8, 2015
bf0768e
Add the -p (--pidfile) option
lopter Nov 8, 2015
b8954f0
Install examples in share/lightsd insted of share/doc/lightsd
lopter Nov 8, 2015
e02c0da
Add a docs CMake target to easily call sphinx-build
lopter Nov 8, 2015
55b26c2
Update the changelog for 1.1.0
lopter Nov 8, 2015
8528817
Added tag 1.1.0 for changeset 39e9e2070a25
lopter Nov 8, 2015
b5c1f8b
Fix dpkg -i command in the documentation
lopter Nov 8, 2015
b351aa2
Document how to run lightsd on OpenWRT trunk
lopter Nov 9, 2015
be10697
Update supported OSes in the README
lopter Nov 9, 2015
3982f66
Fix journalctl command in the documentation
lopter Nov 9, 2015
8499995
Setup the LIFX client source to get unicast responses.
lopter Nov 15, 2015
02341a4
Finish refactoring tests around wire_proto.c
lopter Nov 17, 2015
76748dc
Added tag 1.1.1 for changeset c3284cd6d1af
lopter Nov 17, 2015
dfc831a
Bump the bulb timeout from 3s to 20s
lopter Nov 30, 2015
c851d6a
Improve LIFX traffic logging
lopter Nov 30, 2015
978c99c
Fix LIFX v2 protocol handling
lopter Nov 30, 2015
829292b
Update docs for 1.1.2
lopter Nov 30, 2015
4b30e95
Added tag 1.1.2 for changeset a4a1ac21d226
lopter Nov 30, 2015
065a81e
Remove a note that only applied to fw 1.1 of the Original from the docs
lopter Dec 3, 2015
d138592
Move call to action at the end of the first step guide
lopter Dec 5, 2015
54c3ea6
Docs improvements, add a contribution guide kinda doubles as a manifesto
lopter Dec 27, 2015
e222d4e
Keep working on the documentation
lopter Dec 27, 2015
b36893e
Remove the title from the README
lopter Dec 27, 2015
29ef3c8
Put a title back in the README, minor adjustments
lopter Dec 27, 2015
f029a4b
Document semver a little bit better
lopter Jan 4, 2016
8ffd780
Fix lightsc.py's read loop and document it
lopter Jan 4, 2016
2ffaf3a
Add missing call to action in the dpkg build instructions
lopter Jan 4, 2016
78783c5
Use apt-get to install packages on Debian based systems
lopter Jan 4, 2016
2f7018d
Add freebsd rc script
May 9, 2016
805f7f4
add generic flags section
May 9, 2016
bca656c
put in pid dir creation
May 10, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .hgignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.*\.sw[p-z]$
.*\.sw[a-z]$
.*\.py[co]$
^build
^pcaps
10 changes: 10 additions & 0 deletions .hgtags
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
38014f13f04d5871b70278518221a937867fd8b6 0.9.0
21d438d34e21479a652ba6aa1ec14646385cae5a 0.9.1
3a4befe8819ea7a81f89a6ed550cc88803108f6a 0.9.2
8a41f4cfee7e6ea6d7e161f4e96cfc45bb485cc4 0.9.3
4ef909311670c1ab1543793afa327749150bf1e2 0.9.4
31b8ef65d3d239d7e94417de50b4b7e1c6c0a624 1.0.0
1f7c28381493a9e0a24bf5b918d3772241d15587 1.0.1
39e9e2070a25b17fac56ebc61338024b20538cc4 1.1.0
c3284cd6d1af24bff19327344e89032967ce4ad2 1.1.1
a4a1ac21d226ceb82e1a337123e1d5939ed116f0 1.1.2
7 changes: 3 additions & 4 deletions .ycm_extra_conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,9 @@
# Set this to the absolute path to the folder (NOT the file!) containing the
# compile_commands.json file to use that instead of 'flags'. See here for
# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
#
# Most projects will NOT need to set this to anything; you can just change the
# 'flags' list of compilation flags.
compilation_database_folder = ''
compilation_database_folder = os.getenv(
"MY_BUILD", os.path.join(os.getcwd(), "build")
)

if os.path.exists( compilation_database_folder ):
database = ycm_core.CompilationDatabase( compilation_database_folder )
Expand Down
106 changes: 89 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,50 +1,122 @@
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
# it probably works with older versions but this the oldest tested one:
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.9)

PROJECT(LIFXD C)
PROJECT(LIGHTSD C)

SET(CPACK_PACKAGE_VERSION_MAJOR "0")
SET(CPACK_PACKAGE_VERSION_MINOR "0")
SET(CPACK_PACKAGE_VERSION_PATCH "1")
SET(LIFXD_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
SET(CPACK_PACKAGE_VERSION_MAJOR "1")
SET(CPACK_PACKAGE_VERSION_MINOR "1")
SET(CPACK_PACKAGE_VERSION_PATCH "2")
SET(LIGHTSD_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")

MESSAGE(STATUS "lightsd version: ${LIGHTSD_VERSION}")
MESSAGE(STATUS "CMake version: ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION}")
MESSAGE(STATUS "lifxd version: ${LIFXD_VERSION}")
MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
MESSAGE(STATUS "System: ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION}")
MESSAGE(STATUS "Target system: ${CMAKE_SYSTEM_NAME} ${CMAKE_SYSTEM_VERSION} ${CMAKE_SYSTEM_PROCESSOR}")
MESSAGE(STATUS "Install prefix: ${CMAKE_INSTALL_PREFIX}")
MESSAGE(STATUS "Source directory: ${LIFXD_SOURCE_DIR}")
MESSAGE(STATUS "Source directory: ${LIGHTSD_SOURCE_DIR}")

SET(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${LIFXD_SOURCE_DIR}/CMakeScripts)
SET(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH}" "${LIGHTSD_SOURCE_DIR}/CMakeScripts")

ENABLE_TESTING()

### Platform checks ############################################################

# TODO: we need at least 2.0.19-stable because of the logging defines
FIND_PACKAGE(Event2 REQUIRED COMPONENTS core)
FIND_PACKAGE(Endian REQUIRED)
FIND_PACKAGE(Sphinx)

INCLUDE(CheckFunctionExists)
INCLUDE(CheckVariableExists)
INCLUDE(TestBigEndian)

INCLUDE(CompatReallocArray)
INCLUDE(CompatSetProctitle)
INCLUDE(CompatTimeMonotonic)

INCLUDE(CheckTypeSize)
CHECK_TYPE_SIZE(suseconds_t SUSECONDS_T_SIZE)
ADD_DEFINITIONS("-DLIFXD_SUSECONDS_T_SIZE=${SUSECONDS_T_SIZE}")
TEST_BIG_ENDIAN(BIG_ENDIAN_SYSTEM)

### Global definitions #########################################################

SET(CMAKE_C_FLAGS "-pipe -Wextra -Wall -Wstrict-prototypes -std=c99")
INCLUDE(AddAllSubdirectories)
INCLUDE(AddTestFromSources)

SET(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)

SET(CMAKE_C_FLAGS "-pipe ${CMAKE_C_FLAGS}")
STRING(STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}")
STRING(STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wextra -Wall -Wstrict-prototypes -std=c99")
SET(CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE} "")

# Only relevant for the GNU libc:
ADD_DEFINITIONS(
# Only relevant for the GNU libc:
"-D_POSIX_C_SOURCE=200809L"
"-D_BSD_SOURCE=1"
"-D_DEFAULT_SOURCE=1"

"-D_DARWIN_C_SOURCE=1"

"-DLGTD_BIG_ENDIAN_SYSTEM=${BIG_ENDIAN_SYSTEM}"
"-DLGTD_SIZEOF_VOID_P=${CMAKE_SIZEOF_VOID_P}"

"-DLGTD_HAVE_SETPROCTITLE=${HAVE_SETPROCTITLE}"
"-DLGTD_HAVE_REALLOCARRAY=${HAVE_REALLOCARRAY}"

"-DJSMN_STRICT=1"
"-DJSMN_PARENT_LINKS=1"
)

IF (CMAKE_BUILD_TYPE MATCHES "DEBUG")
ADD_DEFINITIONS("-DQUEUE_MACRO_DEBUG=1")
IF (CMAKE_COMPILER_IS_GNUCC)
ADD_DEFINITIONS("-g3" "-ggdb")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g3 -ggdb3")
ENDIF ()
ENDIF ()

INCLUDE_DIRECTORIES(${LIFXD_SOURCE_DIR}/compat/generic ${LIFXD_BINARY_DIR}/compat)
IF (NOT LGTD_RUNTIME_DIRECTORY)
SET(LGTD_RUNTIME_DIRECTORY "${LIGHTSD_BINARY_DIR}")
ENDIF ()
MESSAGE(STATUS "lightsd runtime directory: ${LGTD_RUNTIME_DIRECTORY}")

INCLUDE_DIRECTORIES(
${EVENT2_INCLUDE_DIR}
${LIGHTSD_BINARY_DIR}/compat
${LIGHTSD_BINARY_DIR}/compat/generic
)

ADD_SUBDIRECTORY(compat)
ADD_SUBDIRECTORY(core)
ADD_SUBDIRECTORY(lifx)

# 2.8.11 is the first version with TARGET_INCLUDE_DIRECTORIES:
IF (CMAKE_VERSION VERSION_GREATER 2.8.10)
CONFIGURE_FILE(
CTestCustom.cmake.in "${LIGHTSD_BINARY_DIR}/CTestCustom.cmake" @ONLY
)
ADD_SUBDIRECTORY(tests)
ELSE ()
MESSAGE(
STATUS
"The tests suite requires CMake >= 2.8.11 "
"but you have ${CMAKE_VERSION}, disabling it"
)
ENDIF ()

IF (SPHINX_FOUND)
ADD_SUBDIRECTORY(docs)
ENDIF ()

INSTALL(
FILES COPYING README.rst docs/protocol.rst
DESTINATION share/doc/lightsd
)
INSTALL(
DIRECTORY examples
DESTINATION share/lightsd
USE_SOURCE_PERMISSIONS
REGEX ".*\\.sw.$" EXCLUDE
)
INSTALL(FILES share/lightsc.sh DESTINATION share/lightsd)
INSTALL(FILES dist/lightsd.service DESTINATION lib/systemd/system)
8 changes: 8 additions & 0 deletions CMakeScripts/AddAllSubdirectories.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
FUNCTION(ADD_ALL_SUBDIRECTORIES)
FILE(GLOB SUBDIRECTORIES "*")
FOREACH (ENTRY ${SUBDIRECTORIES})
IF (IS_DIRECTORY ${ENTRY} AND EXISTS "${ENTRY}/CMakeLists.txt")
ADD_SUBDIRECTORY(${ENTRY})
ENDIF ()
ENDFOREACH ()
ENDFUNCTION()
11 changes: 11 additions & 0 deletions CMakeScripts/AddTestFromSources.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FUNCTION(ADD_TEST_FROM_C_SOURCES TEST_SOURCE)
STRING(LENGTH ${TEST_SOURCE} TEST_NAME_LEN)
STRING(LENGTH "test_" PREFIX_LEN)
MATH(EXPR TEST_NAME_LEN "${TEST_NAME_LEN} - 2 - ${PREFIX_LEN}")
STRING(SUBSTRING ${ARGV0} ${PREFIX_LEN} ${TEST_NAME_LEN} TEST_NAME)
ADD_EXECUTABLE(${TEST_NAME} ${TEST_SOURCE})
IF (ARGN)
TARGET_LINK_LIBRARIES(${TEST_NAME} ${ARGN})
ENDIF ()
ADD_TEST(test_${TEST_NAME} ${TEST_NAME})
ENDFUNCTION()
27 changes: 27 additions & 0 deletions CMakeScripts/CompatReallocArray.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
IF (DEFINED HAVE_REALLOCARRAY)
RETURN()
ENDIF ()

MESSAGE(STATUS "Looking for reallocarray")

SET(CMAKE_REQUIRED_QUIET TRUE)
CHECK_FUNCTION_EXISTS("reallocarray" HAVE_REALLOCARRAY)
UNSET(CMAKE_REQUIRED_QUIET)
IF (HAVE_REALLOCARRAY)
MESSAGE(STATUS "Looking for reallocarray - found")
SET(
HAVE_REALLOCARRAY 1
CACHE INTERNAL
"reallocarray found on the system"
)
ELSE ()
MESSAGE(
STATUS
"Looking for reallocarray - not found, using built-in compatibilty file"
)
SET(
HAVE_REALLOCARRAY 0
CACHE INTERNAL
"reallocarray not found, using internal implementation"
)
ENDIF ()
59 changes: 59 additions & 0 deletions CMakeScripts/CompatSetProctitle.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
IF (DEFINED HAVE_SETPROCTITLE)
IF (HAVE_SETPROCTITLE EQUAL 0)
IF (HAVE_CLEARENV)
ADD_DEFINITIONS("-DHAVE_CLEARENV=1")
ENDIF ()
IF (HAVE_GETEXECNAME)
ADD_DEFINITIONS("-DHAVE_GETEXECNAME=1")
ENDIF ()
IF (HAVE___PROGNAME)
ADD_DEFINITIONS("-DHAVE___PROGNAME=1")
ENDIF ()
IF (HAVE_HAVE_PROGRAM_INVOCATION_SHORT_NAME)
ADD_DEFINITIONS("-DHAVE_HAVE_PROGRAM_INVOCATION_SHORT_NAME=1")
ENDIF ()
ENDIF ()
RETURN()
ENDIF ()

MESSAGE(STATUS "Looking for setproctitle")

SET(CMAKE_REQUIRED_QUIET TRUE)
CHECK_FUNCTION_EXISTS("setproctitle" HAVE_SETPROCTITLE)
UNSET(CMAKE_REQUIRED_QUIET)
IF (HAVE_SETPROCTITLE)
MESSAGE(
STATUS
"Looking for setproctitle - found"
)
SET(HAVE_SETPROCTITLE 1 CACHE INTERNAL "setproctitle found on the system")
ELSE ()
MESSAGE(
STATUS
"Looking for setproctitle - not found, using built-in compatibilty file"
)
SET(
HAVE_SETPROCTITLE 0
CACHE INTERNAL
"setproctitle not found, using internal implementation"
)

CHECK_FUNCTION_EXISTS("clearenv" HAVE_CLEARENV)
CHECK_FUNCTION_EXISTS("getexecname" HAVE_GETEXECNAME)
CHECK_VARIABLE_EXISTS("__progname" HAVE___PROGNAME)
CHECK_VARIABLE_EXISTS(
"program_invocation_short_name" HAVE_PROGRAM_INVOCATION_SHORT_NAME
)
IF (HAVE_CLEARENV)
ADD_DEFINITIONS("-DHAVE_CLEARENV=1")
ENDIF ()
IF (HAVE_GETEXECNAME)
ADD_DEFINITIONS("-DHAVE_GETEXECNAME=1")
ENDIF ()
IF (HAVE___PROGNAME)
ADD_DEFINITIONS("-DHAVE___PROGNAME=1")
ENDIF ()
IF (HAVE_HAVE_PROGRAM_INVOCATION_SHORT_NAME)
ADD_DEFINITIONS("-DHAVE_HAVE_PROGRAM_INVOCATION_SHORT_NAME=1")
ENDIF ()
ENDIF ()
41 changes: 29 additions & 12 deletions CMakeScripts/CompatTimeMonotonic.cmake
Original file line number Diff line number Diff line change
@@ -1,31 +1,48 @@
INCLUDE(CheckFunctionExists)

IF (NOT TIME_MONOTONIC_IMPL)
SET(COMPAT_TIME_MONOTONIC_IMPL "${LIFXD_SOURCE_DIR}/compat/${CMAKE_SYSTEM_NAME}/time_monotonic.c")
SET(COMPAT_TIME_MONOTONIC_H "${LIFXD_SOURCE_DIR}/compat/${CMAKE_SYSTEM_NAME}/time_monotonic.h")
SET(GENERIC_TIME_MONOTONIC_IMPL "${LIFXD_SOURCE_DIR}/compat/generic/time_monotonic.c")
SET(GENERIC_TIME_MONOTONIC_H "${LIFXD_SOURCE_DIR}/compat/generic/time_monotonic.h")
IF (NOT TIME_MONOTONIC_LIBRARY)
SET(COMPAT_TIME_MONOTONIC_IMPL "${LIGHTSD_SOURCE_DIR}/compat/${CMAKE_SYSTEM_NAME}/time_monotonic.c")
SET(COMPAT_TIME_MONOTONIC_H "${LIGHTSD_SOURCE_DIR}/compat/${CMAKE_SYSTEM_NAME}/time_monotonic.h")
SET(GENERIC_TIME_MONOTONIC_IMPL "${LIGHTSD_SOURCE_DIR}/compat/generic/time_monotonic.c")
SET(GENERIC_TIME_MONOTONIC_H "${LIGHTSD_SOURCE_DIR}/compat/generic/time_monotonic.h")
SET(TIME_MONOTONIC_LIBRARY time_monotonic CACHE INTERNAL "lgtd_time_monotonic implementation")

SET(CMAKE_REQUIRED_QUIET TRUE)
MESSAGE(STATUS "Looking for clock_gettime")
CHECK_FUNCTION_EXISTS("clock_gettime" HAVE_CLOCK_GETTIME)
IF (NOT HAVE_CLOCK_GETTIME)
# glibc < 2.17:
MESSAGE(STATUS "Looking for clock_gettime again in librt")
UNSET(HAVE_CLOCK_GETTIME CACHE)
SET(TIME_MONOTONIC_LIBRARY_DEP rt CACHE INTERNAL "dependency for lgtd_time_monotonic")
SET(CMAKE_REQUIRED_LIBRARIES ${TIME_MONOTONIC_LIBRARY_DEP})
CHECK_FUNCTION_EXISTS("clock_gettime" HAVE_CLOCK_GETTIME)
UNSET(CMAKE_REQUIRED_LIBRARIES)
IF (NOT HAVE_CLOCK_GETTIME)
UNSET(TIME_MONOTONIC_LIBRARY_DEP CACHE)
ENDIF ()
ENDIF ()
UNSET(CMAKE_REQUIRED_QUIET)

IF (HAVE_CLOCK_GETTIME)
MESSAGE(STATUS "Looking for clock_gettime - found")
FILE(COPY "${GENERIC_TIME_MONOTONIC_H}" DESTINATION "${LIFXD_BINARY_DIR}/compat/")
FILE(COPY "${GENERIC_TIME_MONOTONIC_H}" DESTINATION "${LIGHTSD_BINARY_DIR}/core/")
SET(
TIME_MONOTONIC_IMPL "${GENERIC_TIME_MONOTONIC_IMPL}"
CACHE INTERNAL "lifxd_time_monotonic (POSIX generic implementation)"
TIME_MONOTONIC_IMPL ${GENERIC_TIME_MONOTONIC_IMPL}
CACHE INTERNAL "lgtd_time_monotonic (POSIX generic source)"
)
ELSEIF (EXISTS "${COMPAT_TIME_MONOTONIC_IMPL}")
MESSAGE(STATUS "Looking for clock_gettime - not found, using built-in compatibilty file")
FILE(COPY "${COMPAT_TIME_MONOTONIC_H}" DESTINATION "${LIFXD_BINARY_DIR}/compat/")
FILE(COPY "${COMPAT_TIME_MONOTONIC_H}" DESTINATION "${LIGHTSD_BINARY_DIR}/core/")
SET(
TIME_MONOTONIC_IMPL "${COMPAT_TIME_MONOTONIC_IMPL}"
CACHE INTERNAL "lifxd_time_monotonic (${CMAKE_SYSTEM_NAME} specific implementation)"
CACHE INTERNAL "lgtd_time_monotonic (${CMAKE_SYSTEM_NAME} specific source)"
)
ELSE ()
MESSAGE(SEND_ERROR "Looking for clock_gettime - not found")
ENDIF ()
ENDIF ()

ADD_LIBRARY(${TIME_MONOTONIC_LIBRARY} STATIC "${TIME_MONOTONIC_IMPL}")

IF (TIME_MONOTONIC_LIBRARY_DEP)
TARGET_LINK_LIBRARIES(${TIME_MONOTONIC_LIBRARY} ${TIME_MONOTONIC_LIBRARY_DEP})
ENDIF ()
8 changes: 4 additions & 4 deletions CMakeScripts/FindEndian.cmake
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
INCLUDE(CheckIncludeFile)

IF (NOT ENDIAN_H_PATH)
SET(COMPAT_ENDIAN_H "${LIFXD_SOURCE_DIR}/compat/${CMAKE_SYSTEM_NAME}/endian.h")
SET(GENERIC_ENDIAN_H "${LIFXD_SOURCE_DIR}/compat/generic/endian.h")
SET(COMPAT_ENDIAN_H "${LIGHTSD_SOURCE_DIR}/compat/${CMAKE_SYSTEM_NAME}/endian.h")
SET(GENERIC_ENDIAN_H "${LIGHTSD_SOURCE_DIR}/compat/generic/endian.h")

SET(CMAKE_REQUIRED_QUIET TRUE)
MESSAGE(STATUS "Looking for endian.h")
CHECK_INCLUDE_FILE("endian.h" HAVE_ENDIAN_H)
UNSET(CMAKE_REQUIRED_QUIET)

IF (HAVE_ENDIAN_H)
MESSAGE(STATUS "Looking for endan.h - found")
MESSAGE(STATUS "Looking for endian.h - found")
SET(ENDIAN_H_PATH "using native headers" CACHE INTERNAL "endian.h path")
ELSEIF (EXISTS "${COMPAT_ENDIAN_H}")
MESSAGE(STATUS "Looking for endian.h - not found, using built-in compatibility file")
FILE(COPY "${COMPAT_ENDIAN_H}" DESTINATION "${LIFXD_BINARY_DIR}/compat/")
FILE(COPY "${COMPAT_ENDIAN_H}" DESTINATION "${LIGHTSD_BINARY_DIR}/compat/")
SET(ENDIAN_H_PATH "${COMPAT_ENDIAN_H}" CACHE INTERNAL "endian.h path")
ELSE ()
MESSAGE(STATUS "Looking for endian.h - not found")
Expand Down
14 changes: 10 additions & 4 deletions CMakeScripts/FindEvent2.cmake
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
FIND_PATH(
EVENT2_INCLUDE_DIR
event2/event.h
# OpenBSD has libevent1 in /usr/lib, always try /usr/local first:
HINTS /usr/local/
)

FOREACH (COMPONENT ${Event2_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPER_COMPONENT)
FIND_LIBRARY(EVENT2_${UPPER_COMPONENT}_LIBRARY event_${COMPONENT})
FIND_LIBRARY(
EVENT2_${UPPER_COMPONENT}_LIBRARY event_${COMPONENT} HINTS /usr/local/
)
IF (EVENT2_${UPPER_COMPONENT}_LIBRARY)
SET(Event2_${COMPONENT}_FOUND TRUE)
ENDIF ()
ENDFOREACH ()

FIND_PATH(EVENT2_INCLUDE_DIR event2/event.h)

INCLUDE(FindPackageHandleStandardArgs)

FIND_PACKAGE_HANDLE_STANDARD_ARGS(
Event2
FOUND_VAR Event2_FOUND
HANDLE_COMPONENTS
REQUIRED_VARS EVENT2_CORE_LIBRARY EVENT2_INCLUDE_DIR
)
Loading