Skip to content

Commit

Permalink
Added install target
Browse files Browse the repository at this point in the history
  • Loading branch information
aul12 committed Mar 9, 2019
1 parent de65f67 commit 8813ae3
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 19 deletions.
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,15 @@ endif()
set(QT_LIBS Qt5::Core Qt5::Widgets Qt5::Quick Qt5::UiTools)
set(LIBS stdc++fs pthread ${QT_LIBS})

add_definitions(-DUI_FILE_LOCATION="${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/main.ui")

add_executable(${PROJECT_NAME} main.cpp ${SOURCES})

target_link_libraries(${PROJECT_NAME} ${GTKMM_LIBRARIES} ${LIBS})

install(TARGETS ${PROJECT_NAME}
DESTINATION bin/)
install(FILES Res/main.ui DESTINATION share/${PROJECT_NAME}/)

add_subdirectory(Tests)

33 changes: 17 additions & 16 deletions Tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
project(Tests)

enable_testing()
find_package(GTest REQUIRED)
include_directories(${GTEST_INCLUDE_DIR})
find_package(GTest)
if (GTest_FOUND)
include_directories(${GTEST_INCLUDE_DIR})

set(TEST_SOURCES
${CMAKE_SOURCE_DIR}/Tests/Util/Listener.cpp
${CMAKE_SOURCE_DIR}/Tests/Controller/SerialProxy.cpp
${CMAKE_SOURCE_DIR}/Tests/Controller/UiController.cpp
${CMAKE_SOURCE_DIR}/Tests/Controller/LineBreakStateMachine.cpp
${CMAKE_SOURCE_DIR}/Tests/Util/Serial/Interface.cpp)
set(TEST_SOURCES
${CMAKE_SOURCE_DIR}/Tests/Util/Listener.cpp
${CMAKE_SOURCE_DIR}/Tests/Controller/SerialProxy.cpp
${CMAKE_SOURCE_DIR}/Tests/Controller/UiController.cpp
${CMAKE_SOURCE_DIR}/Tests/Controller/LineBreakStateMachine.cpp
${CMAKE_SOURCE_DIR}/Tests/Util/Serial/Interface.cpp)

include_directories(${CMAKE_SOURCE_DIR})
include_directories(${CMAKE_SOURCE_DIR})

add_executable(${PROJECT_NAME} main.cpp ${SOURCES} ${TEST_SOURCES})
add_executable(${PROJECT_NAME} main.cpp ${SOURCES} ${TEST_SOURCES})

target_link_libraries(${PROJECT_NAME} ${GTKMM_LIBRARIES} ${LIBS} gmock gtest)

add_test(
NAME ${PROJECT_NAME}
COMMAND ${PROJECT_NAME}
)
target_link_libraries(${PROJECT_NAME} ${GTKMM_LIBRARIES} ${LIBS} gmock gtest)

add_test(
NAME ${PROJECT_NAME}
COMMAND ${PROJECT_NAME}
)
endif()
2 changes: 1 addition & 1 deletion View/MainView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,4 +318,4 @@ namespace view {
listLock.unlock();
}
}
}
}
8 changes: 6 additions & 2 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
int main(int argc, char *argv[]) {
QApplication app (argc, argv);

auto mainView = std::make_shared<view::MainView>("Res/main.ui");
std::string uiFile = UI_FILE_LOCATION;
if (argc == 2) {
uiFile = argv[1];
}
auto mainView = std::make_shared<view::MainView>(uiFile);
controller::UiController uiController{mainView};

QApplication::exec();

return 0;
}
}

0 comments on commit 8813ae3

Please sign in to comment.