|
1 | | -cmake_minimum_required(VERSION 3.5) |
| 1 | +cmake_minimum_required(VERSION 3.16) |
2 | 2 |
|
3 | 3 | project(ModbusSim |
4 | 4 | LANGUAGES CXX |
5 | | - DESCRIPTION "Test module to test Modbus communication" |
| 5 | + DESCRIPTION "Modbus Slave Simulation" |
6 | 6 | VERSION 0.0.0 |
7 | 7 | ) |
8 | 8 |
|
9 | 9 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) |
10 | 10 |
|
11 | | -# As moc files are generated in the binary dir, tell CMake |
12 | | -# to always look for includes there: |
13 | | -set(CMAKE_INCLUDE_CURRENT_DIR ON) |
14 | | - |
15 | 11 | set(CMAKE_CXX_STANDARD 11) |
16 | 12 | set(CMAKE_CXX_STANDARD_REQUIRED ON) |
17 | 13 |
|
@@ -60,25 +56,34 @@ SET(TESTSLAVE_SRCS |
60 | 56 | ${CMAKE_CURRENT_SOURCE_DIR}/testslave/testslavemodbus.cpp |
61 | 57 | ) |
62 | 58 |
|
63 | | -# set platform specific for compilation |
| 59 | +# Default GUI type is blank |
| 60 | +set(GUI_TYPE "") |
| 61 | + |
64 | 62 | if(WIN32) |
| 63 | + set(GUI_TYPE WIN32) |
65 | 64 | set(target_dir "bin/win") |
66 | 65 | elseif(${CMAKE_SYSTEM_NAME} MATCHES "Linux") |
67 | 66 | set(target_dir "bin/linux") |
68 | 67 | else() |
69 | | - message(SEND_ERROR "You are on an unsupported platform! (Not Win, Mac OS X or Unix)") |
| 68 | + message(SEND_ERROR "You are on an unsupported platform! (Not Win or Unix)") |
70 | 69 | endif(WIN32) |
71 | 70 |
|
72 | | -add_executable(modbussim ${APP_SRCS} ${TESTSLAVE_SRCS}) |
| 71 | +add_executable(${PROJECT_NAME} ${GUI_TYPE} ${APP_SRCS} ${TESTSLAVE_SRCS}) |
73 | 72 |
|
74 | | -set_target_properties(modbussim PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${target_dir} ) |
| 73 | +set_target_properties(${PROJECT_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${target_dir} ) |
| 74 | + |
| 75 | +target_link_libraries(${PROJECT_NAME} PRIVATE |
| 76 | + ${SCOPESOURCE} |
| 77 | + ${QT_LIB} |
| 78 | +) |
75 | 79 |
|
76 | | -target_link_libraries(modbussim ${QT_LIB}) |
| 80 | +# Reset GUI type to blank |
| 81 | +set(GUI_TYPE "") |
77 | 82 |
|
78 | 83 | # Do platform specific post target stuff |
79 | 84 | if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") |
80 | 85 |
|
81 | | - install(TARGETS modbussim RUNTIME DESTINATION bin) |
| 86 | + install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin) |
82 | 87 |
|
83 | 88 | elseif(WIN32) |
84 | 89 | # not required |
|
0 commit comments