aboutsummaryrefslogtreecommitdiff
path: root/apps/CMakeLists.txt
diff options
context:
space:
mode:
Diffstat (limited to 'apps/CMakeLists.txt')
-rw-r--r--apps/CMakeLists.txt74
1 files changed, 29 insertions, 45 deletions
diff --git a/apps/CMakeLists.txt b/apps/CMakeLists.txt
index 8ba5a0a..b8255d1 100644
--- a/apps/CMakeLists.txt
+++ b/apps/CMakeLists.txt
@@ -9,6 +9,16 @@ list(APPEND APPS sm-get-value)
list(APPEND APPS sm-serial-read)
list(APPEND APPS sm-serial-read-all)
+add_library(apps OBJECT
+ apps.cpp apps.h
+ SoilMoisture.cpp SoilMoisture.h)
+target_include_directories(apps
+ PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
+ PUBLIC "${PROJECT_SOURCE_DIR}/include"
+ PUBLIC "${PROJECT_SOURCE_DIR}/json/src"
+ PUBLIC "${PROJECT_SOURCE_DIR}/sensor/include"
+ PUBLIC "${LOG4CPLUS_INCLUDE_DIRECTORIES}")
+
# Boost
find_package(Boost COMPONENTS regex system program_options REQUIRED)
@@ -30,50 +40,24 @@ if(LOG4CPLUS_LIBRARIES MATCHES NOTFOUND)
message(FATAL_ERROR "Could not find log4cplus library files")
endif()
-add_executable(generate generate.cpp)
-
-file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/generated)
-
-add_custom_command(
- OUTPUT generated/apps-list.gen.h
- COMMAND generate ${CMAKE_CURRENT_BINARY_DIR}/generated/apps-list.gen.h ${APPS}
- DEPENDS generate ${CMAKE_CURRENT_SOURCE_DIR}/CMakeLists.txt)
-
-foreach(app ${APPS})
- list(APPEND APPS_SOURCES ${app}.h)
-endforeach()
-
-list(APPEND SOURCES ${CMAKE_CURRENT_BINARY_DIR}/generated/apps-list.gen.h)
-list(APPEND SOURCES SoilMoisture.cpp SoilMoisture.h)
-list(APPEND SOURCES apps.cpp apps.h)
-
-add_executable(launcher launcher.cpp
- ${SOURCES}
- ${APPS_SOURCES})
-target_include_directories(launcher
- PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/generated
- PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
- PUBLIC "${PROJECT_SOURCE_DIR}/include"
- PUBLIC "${PROJECT_SOURCE_DIR}/json/src"
- PUBLIC "${PROJECT_SOURCE_DIR}/sensor/include"
- PUBLIC "${LOG4CPLUS_INCLUDE_DIRECTORIES}")
-
-target_link_libraries(launcher ble)
-target_link_libraries(launcher trygvis-sensor)
-target_link_libraries(launcher ${Boost_LIBRARIES})
-target_link_libraries(launcher ${BLUEZ_LIBRARIES})
-target_link_libraries(launcher ${PQXX_LIBRARIES})
-target_link_libraries(launcher ${LOG4CPLUS_LIBRARIES})
-target_link_libraries(launcher ${CMAKE_THREAD_LIBS_INIT})
-
foreach(app ${APPS})
- add_custom_command(
- TARGET launcher POST_BUILD
- COMMAND ln -sf ../libexec/launcher ${app})
-
- install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${app} DESTINATION bin)
+ add_executable(${app} ${app}.cpp $<TARGET_OBJECTS:apps>)
+
+ target_include_directories(${app}
+ PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
+ PUBLIC "${PROJECT_SOURCE_DIR}/include"
+ PUBLIC "${PROJECT_SOURCE_DIR}/json/src"
+ PUBLIC "${PROJECT_SOURCE_DIR}/sensor/include"
+ PUBLIC "${LOG4CPLUS_INCLUDE_DIRECTORIES}")
+
+ target_link_libraries(${app}
+ ble
+ trygvis-sensor
+ ${Boost_LIBRARIES}
+ ${BLUEZ_LIBRARIES}
+ ${PQXX_LIBRARIES}
+ ${LOG4CPLUS_LIBRARIES}
+ ${CMAKE_THREAD_LIBS_INIT})
+
+ install(TARGETS ${app} RUNTIME DESTINATION bin)
endforeach()
-
-set_target_properties(launcher PROPERTIES INSTALL_RPATH "\\$ORIGIN/../lib/trygvis")
-install(TARGETS launcher
- RUNTIME DESTINATION libexec)