Sfoglia il codice sorgente

Put binaries in bin folder instead of build (#945)

* Added visual studio solution folders

* Added solution folders for examples and lint

* Changed output folder for binaries to bin

* Add subdirectory for example binaries

* Maybe fixed travis stuff?

* Travis fixes.

* Added bin directory to tests cmakelists

* Change test binary dir for valgrind?
Mark Giraud 7 anni fa
parent
commit
94e9a6edf8

+ 8 - 0
CMakeLists.txt

@@ -6,6 +6,14 @@ set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/tools/cmake")
 find_package(PythonInterp REQUIRED)
 find_package(Git)
 
+#############################
+# Compiled binaries folders #
+#############################
+
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin)
+
 #################
 # Cmake modules #
 #################

+ 9 - 0
examples/CMakeLists.txt

@@ -1,6 +1,15 @@
 include_directories(${PROJECT_SOURCE_DIR}/include)
 include_directories(${PROJECT_SOURCE_DIR}/plugins)
 
+#############################
+# Compiled binaries folders #
+#############################
+
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/examples)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/examples)
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/examples)
+#######
+
 if(UA_ENABLE_AMALGAMATION)
     include_directories(${PROJECT_BINARY_DIR}) # contain open62541.h
 else()

+ 31 - 20
tests/CMakeLists.txt

@@ -5,6 +5,17 @@ include_directories(${PROJECT_SOURCE_DIR}/plugins)
 include_directories(${PROJECT_BINARY_DIR}/src_generated)
 include_directories(${CHECK_INCLUDE_DIRS})
 
+#############################
+# Compiled binaries folders #
+#############################
+
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/tests)
+set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/tests)
+set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin/tests)
+###
+
+set(TESTS_BINARY_DIR ${CMAKE_SOURCE_DIR}/bin/tests)
+
 find_package(Check REQUIRED)
 find_package(Threads REQUIRED)
 if(UA_ENABLE_VALGRIND_UNIT_TESTS)
@@ -43,65 +54,65 @@ endmacro()
 
 add_executable(check_types_builtin check_types_builtin.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_types_builtin ${LIBS})
-add_test_valgrind(types_builtin ${CMAKE_CURRENT_BINARY_DIR}/check_types_builtin)
+add_test_valgrind(types_builtin ${TESTS_BINARY_DIR}/check_types_builtin)
 
 add_executable(check_types_memory check_types_memory.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_types_memory ${LIBS})
-add_test_valgrind(types_memory ${CMAKE_CURRENT_BINARY_DIR}/check_types_memory)
+add_test_valgrind(types_memory ${TESTS_BINARY_DIR}/check_types_memory)
 
 add_executable(check_types_range check_types_range.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_types_range ${LIBS})
-add_test_valgrind(types_range ${CMAKE_CURRENT_BINARY_DIR}/check_types_range)
+add_test_valgrind(types_range ${TESTS_BINARY_DIR}/check_types_range)
 
 add_executable(check_types_custom check_types_custom.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_types_custom ${LIBS})
-add_test_valgrind(types_custom ${CMAKE_CURRENT_BINARY_DIR}/check_types_custom)
+add_test_valgrind(types_custom ${TESTS_BINARY_DIR}/check_types_custom)
 
 add_executable(check_chunking check_chunking.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_chunking ${LIBS})
-add_test_valgrind(chunking ${CMAKE_CURRENT_BINARY_DIR}/check_chunking)
+add_test_valgrind(chunking ${TESTS_BINARY_DIR}/check_chunking)
 
 add_executable(check_utils check_utils.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_utils ${LIBS})
-add_test_valgrind(check_utils ${CMAKE_CURRENT_BINARY_DIR}/check_utils)
+add_test_valgrind(check_utils ${TESTS_BINARY_DIR}/check_utils)
 
 # Test Server
 
 add_executable(check_services_view check_services_view.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_services_view ${LIBS})
-add_test_valgrind(services_view ${CMAKE_CURRENT_BINARY_DIR}/check_services_view)
+add_test_valgrind(services_view ${TESTS_BINARY_DIR}/check_services_view)
 
 add_executable(check_services_attributes check_services_attributes.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_services_attributes ${LIBS})
-add_test_valgrind(services_attributes ${CMAKE_CURRENT_BINARY_DIR}/check_services_attributes)
+add_test_valgrind(services_attributes ${TESTS_BINARY_DIR}/check_services_attributes)
 
 add_executable(check_services_nodemanagement check_services_nodemanagement.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_services_nodemanagement ${LIBS})
-add_test_valgrind(services_nodemanagement ${CMAKE_CURRENT_BINARY_DIR}/check_services_nodemanagement)
+add_test_valgrind(services_nodemanagement ${TESTS_BINARY_DIR}/check_services_nodemanagement)
 
 add_executable(check_services_subscriptions check_services_subscriptions.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_services_subscriptions ${LIBS})
-add_test_valgrind(check_services_subscriptions ${CMAKE_CURRENT_BINARY_DIR}/check_services_subscriptions)
+add_test_valgrind(check_services_subscriptions ${TESTS_BINARY_DIR}/check_services_subscriptions)
 
 add_executable(check_nodestore check_nodestore.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_nodestore ${LIBS})
-add_test_valgrind(nodestore ${CMAKE_CURRENT_BINARY_DIR}/check_nodestore)
+add_test_valgrind(nodestore ${TESTS_BINARY_DIR}/check_nodestore)
 
 add_executable(check_session check_session.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_session ${LIBS})
-add_test_valgrind(session ${CMAKE_CURRENT_BINARY_DIR}/check_session)
+add_test_valgrind(session ${TESTS_BINARY_DIR}/check_session)
 
 add_executable(check_server_jobs check_server_jobs.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_server_jobs ${LIBS})
-add_test_valgrind(check_server_jobs ${CMAKE_CURRENT_BINARY_DIR}/check_server_jobs)
+add_test_valgrind(check_server_jobs ${TESTS_BINARY_DIR}/check_server_jobs)
 
 add_executable(check_server_userspace check_server_userspace.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_server_userspace ${LIBS})
-add_test_valgrind(check_server_userspace ${CMAKE_CURRENT_BINARY_DIR}/check_server_userspace)
+add_test_valgrind(check_server_userspace ${TESTS_BINARY_DIR}/check_server_userspace)
 
 add_executable(check_discovery check_discovery.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_discovery ${LIBS})
-add_test_valgrind(discovery ${CMAKE_CURRENT_BINARY_DIR}/check_discovery)
+add_test_valgrind(discovery ${TESTS_BINARY_DIR}/check_discovery)
 
 # Test server with network dumps from files
 
@@ -134,19 +145,19 @@ target_include_directories(check_server_binary_messages PRIVATE ${PROJECT_SOURCE
 target_link_libraries(check_server_binary_messages ${LIBS})
 add_dependencies(check_server_binary_messages client_HELOPN.bin)
 
-add_test_valgrind(check_server_binary_messages_browse ${CMAKE_CURRENT_BINARY_DIR}/check_server_binary_messages
+add_test_valgrind(check_server_binary_messages_browse ${TESTS_BINARY_DIR}/check_server_binary_messages
                                              ${CMAKE_CURRENT_BINARY_DIR}/client_HELOPN.bin
                                              ${CMAKE_CURRENT_BINARY_DIR}/client_CreateActivateSession.bin
                                              ${CMAKE_CURRENT_BINARY_DIR}/client_Browse.bin
                                              ${CMAKE_CURRENT_BINARY_DIR}/client_CLO.bin)
 
-add_test_valgrind(check_server_binary_messages_read ${CMAKE_CURRENT_BINARY_DIR}/check_server_binary_messages
+add_test_valgrind(check_server_binary_messages_read ${TESTS_BINARY_DIR}/check_server_binary_messages
                                            ${CMAKE_CURRENT_BINARY_DIR}/client_HELOPN.bin
                                            ${CMAKE_CURRENT_BINARY_DIR}/client_CreateActivateSession.bin
                                            ${CMAKE_CURRENT_BINARY_DIR}/client_Read.bin
                                            ${CMAKE_CURRENT_BINARY_DIR}/client_CLO.bin)
 
-add_test_valgrind(check_server_binary_messages_write ${CMAKE_CURRENT_BINARY_DIR}/check_server_binary_messages
+add_test_valgrind(check_server_binary_messages_write ${TESTS_BINARY_DIR}/check_server_binary_messages
                                            ${CMAKE_CURRENT_BINARY_DIR}/client_HELOPN.bin
                                            ${CMAKE_CURRENT_BINARY_DIR}/client_CreateActivateSession.bin
                                            ${CMAKE_CURRENT_BINARY_DIR}/client_Write.bin
@@ -156,8 +167,8 @@ add_test_valgrind(check_server_binary_messages_write ${CMAKE_CURRENT_BINARY_DIR}
 
 add_executable(check_client check_client.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_client ${LIBS})
-add_test_valgrind(check_client ${CMAKE_CURRENT_BINARY_DIR}/check_client)
+add_test_valgrind(check_client ${TESTS_BINARY_DIR}/check_client)
 
 add_executable(check_client_subscriptions check_client_subscriptions.c $<TARGET_OBJECTS:open62541-object>)
 target_link_libraries(check_client_subscriptions ${LIBS})
-add_test_valgrind(check_client_subscriptions ${CMAKE_CURRENT_BINARY_DIR}/check_client_subscriptions)
+add_test_valgrind(check_client_subscriptions ${TESTS_BINARY_DIR}/check_client_subscriptions)

+ 7 - 7
tools/travis/travis_linux_script.sh

@@ -69,7 +69,7 @@ else
         mkdir -p build && cd build
         cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-mingw32.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
         make -j
-        zip -r open62541-win32.zip ../../doc_latex/open62541.pdf ../LICENSE ../AUTHORS ../README.md examples/server.exe examples/client.exe libopen62541.dll.a open62541.h open62541.c
+        zip -r open62541-win32.zip ../../doc_latex/open62541.pdf ../LICENSE ../AUTHORS ../README.md ../bin/examples/server.exe ../bin/examples/client.exe ../bin/libopen62541.dll.a open62541.h open62541.c
         cp open62541-win32.zip ..
         cd .. && rm build -rf
 
@@ -77,7 +77,7 @@ else
         mkdir -p build && cd build
         cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-mingw64.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
         make -j
-        zip -r open62541-win64.zip ../../doc_latex/open62541.pdf ../LICENSE ../AUTHORS ../README.md examples/server.exe examples/client.exe libopen62541.dll.a open62541.h open62541.c
+        zip -r open62541-win64.zip ../../doc_latex/open62541.pdf ../LICENSE ../AUTHORS ../README.md ../bin/examples/server.exe ../bin/examples/client.exe ../bin/libopen62541.dll.a open62541.h open62541.c
         cp open62541-win64.zip ..
         cd .. && rm build -rf
 
@@ -85,7 +85,7 @@ else
         mkdir -p build && cd build
         cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-gcc-m32.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
         make -j
-        tar -pczf open62541-linux32.tar.gz ../../doc_latex/open62541.pdf ../LICENSE ../AUTHORS ../README.md examples/server examples/client libopen62541.a open62541.h open62541.c
+        tar -pczf open62541-linux32.tar.gz ../../doc_latex/open62541.pdf ../LICENSE ../AUTHORS ../README.md ../bin/examples/server ../bin/examples/client ../bin/libopen62541.a open62541.h open62541.c
         cp open62541-linux32.tar.gz ..
         cd .. && rm build -rf
 
@@ -95,7 +95,7 @@ else
         export PATH=$PATH:./tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/
         cmake -DCMAKE_TOOLCHAIN_FILE=../tools/cmake/Toolchain-rpi64.cmake -DUA_ENABLE_AMALGAMATION=ON -DCMAKE_BUILD_TYPE=Release -DUA_BUILD_EXAMPLES=ON ..
         make -j
-        tar -pczf open62541-raspberrypi.tar.gz ../../doc_latex/open62541.pdf ../LICENSE ../AUTHORS ../README.md examples/server examples/client libopen62541.a open62541.h open62541.c
+        tar -pczf open62541-raspberrypi.tar.gz ../../doc_latex/open62541.pdf ../LICENSE ../AUTHORS ../README.md ../bin/examples/server ../bin/examples/client ../bin/libopen62541.a open62541.h open62541.c
         cp open62541-raspberrypi.tar.gz ..
         cd .. && rm build -rf
     fi
@@ -104,7 +104,7 @@ else
     mkdir -p build && cd build
     cmake -DCMAKE_BUILD_TYPE=Release -DUA_ENABLE_AMALGAMATION=ON -DUA_BUILD_EXAMPLES=ON ..
     make -j
-    tar -pczf open62541-linux64.tar.gz ../../doc_latex/open62541.pdf ../LICENSE ../AUTHORS ../README.md examples/server examples/client libopen62541.a open62541.h open62541.c
+    tar -pczf open62541-linux64.tar.gz ../../doc_latex/open62541.pdf ../LICENSE ../AUTHORS ../README.md ../bin/examples/server ../bin/examples/client ../bin/libopen62541.a open62541.h open62541.c
     cp open62541-linux64.tar.gz ..
     cp open62541.h ../.. # copy single file-release
     cp open62541.c ../.. # copy single file-release
@@ -133,11 +133,11 @@ else
     mkdir -p build && cd build
     cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_ENABLE_COVERAGE=ON -DUA_ENABLE_VALGRIND_UNIT_TESTS=ON ..
     make -j && make test ARGS="-V"
-    (valgrind --leak-check=yes --error-exitcode=3 ./examples/server & export pid=$!; sleep 2; kill -INT $pid; wait $pid);
+    (valgrind --leak-check=yes --error-exitcode=3 ../bin/examples/server & export pid=$!; sleep 2; kill -INT $pid; wait $pid);
     # without valgrind
     cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_EXAMPLES=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_ENABLE_COVERAGE=ON ..
     make -j && make test ARGS="-V"
-    (./examples/server & export pid=$!; sleep 2; kill -INT $pid; wait $pid);
+    (../bin/examples/server & export pid=$!; sleep 2; kill -INT $pid; wait $pid);
     # only run coveralls on main repo, otherwise it fails uploading the files
     echo "-> Current repo: ${TRAVIS_REPO_SLUG}"
     if [ "$CC" = "gcc" ] && [ "${TRAVIS_REPO_SLUG}" = "open62541/open62541" ]; then

+ 2 - 2
tools/travis/travis_osx_script.sh

@@ -18,7 +18,7 @@ else
     mkdir -p build && cd build
     cmake -DCMAKE_BUILD_TYPE=Release -DUA_ENABLE_AMALGAMATION=ON -DUA_BUILD_EXAMPLES=ON -DUA_BUILD_DOCUMENTATION=ON -DUA_GENERATE_SELFSIGNED=ON ..
     make -j8
-    tar -pczf open62541-osx.tar.gz ../doc ../server_cert.der ../LICENSE ../AUTHORS ../README.md examples/server examples/client libopen62541.a open62541.h open62541.c
+    tar -pczf open62541-osx.tar.gz ../doc ../server_cert.der ../LICENSE ../AUTHORS ../README.md ../bin/examples/server ../bin/examples/client ../bin/libopen62541.a open62541.h open62541.c
     cp open62541-osx.tar.gz ..
     cp open62541.h .. #copy single file-release
     cp open62541.c .. #copy single file-release
@@ -41,6 +41,6 @@ else
     cmake -DCMAKE_BUILD_TYPE=Debug -DUA_BUILD_DEMO_NODESET=ON -DUA_BUILD_UNIT_TESTS=ON -DUA_BUILD_EXAMPLES=ON -DUA_ENABLE_COVERAGE=ON ..
     make -j8 && make test
     echo "Run valgrind to see if the server leaks memory (just starting up and closing..)"
-    (valgrind --error-exitcode=3 ./server & export pid=$!; sleep 2; kill -INT $pid; wait $pid);
+    (valgrind --error-exitcode=3 ../bin/server & export pid=$!; sleep 2; kill -INT $pid; wait $pid);
     cd .. && rm -rf build
 fi