Browse Source

Do not build sample app executable when building unit tests.

Unit tests define an OPENER_ASSERT macro that requires linkage to a function
defined in OpENerTests.cpp, which is not compiled for the sample application.
Unit tests are built into a separate executable, so building the sample is
not required anyway.
Jason Valenzuela 4 years ago
parent
commit
66020105c0

+ 4 - 3
source/src/ports/MINGW/CMakeLists.txt

@@ -16,9 +16,10 @@ set (PLATFORMLIBNAME ${OpENer_PLATFORM}PLATFORM)
 
 add_library( ${PLATFORMLIBNAME} ${PLATFORM_SPEC_SRC})
 
-add_executable(OpENer main.c)
-
-target_link_libraries( OpENer PLATFORM_GENERIC ${PLATFORMLIBNAME} CIP Utils SAMPLE_APP ENET_ENCAP NVDATA ws2_32 iphlpapi ${OpENer_CIP_OBJECTS} )
+if( NOT OpENer_TESTS)
+  add_executable(OpENer main.c)
+  target_link_libraries( OpENer PLATFORM_GENERIC ${PLATFORMLIBNAME} CIP Utils SAMPLE_APP ENET_ENCAP NVDATA ws2_32 iphlpapi ${OpENer_CIP_OBJECTS} )
+endif()
 
 # Add additional CIP Objects
 string(COMPARE NOTEQUAL "${OpENer_ADD_CIP_OBJECTS}" "" OpENer_HAS_ADDITIONAL_OBJECT )

+ 4 - 2
source/src/ports/POSIX/CMakeLists.txt

@@ -47,8 +47,10 @@ if( OPENER_BUILD_SHARED_LIBS )
    )
 endif()
 
-add_executable(OpENer main.c)
-target_link_libraries( OpENer CIP Utils SAMPLE_APP ENET_ENCAP NVDATA PLATFORM_GENERIC ${OpENer_PLATFORM}PLATFORM ${PLATFORM_SPEC_LIBS} CIP rt cap pthread)
+if( NOT OpENer_TESTS)
+  add_executable(OpENer main.c)
+  target_link_libraries( OpENer CIP Utils SAMPLE_APP ENET_ENCAP NVDATA PLATFORM_GENERIC ${OpENer_PLATFORM}PLATFORM ${PLATFORM_SPEC_LIBS} CIP rt cap pthread)
+endif()
 
 # Add additional CIP Objects
 string(COMPARE NOTEQUAL "${OpENer_ADD_CIP_OBJECTS}" "" OpENer_HAS_ADDITIONAL_OBJECT )

+ 4 - 3
source/src/ports/WIN32/CMakeLists.txt

@@ -16,9 +16,10 @@ set (PLATFORMLIBNAME ${OpENer_PLATFORM}PLATFORM)
 
 add_library( ${PLATFORMLIBNAME} ${PLATFORM_SPEC_SRC})
 
-add_executable(OpENer main.c)
-
-target_link_libraries( OpENer PLATFORM_GENERIC ${PLATFORMLIBNAME} CIP Utils  SAMPLE_APP ENET_ENCAP NVDATA ws2_32 Iphlpapi ${OpENer_CIP_OBJECTS} )
+if( NOT OpENer_TESTS)
+  add_executable(OpENer main.c)
+  target_link_libraries( OpENer PLATFORM_GENERIC ${PLATFORMLIBNAME} CIP Utils  SAMPLE_APP ENET_ENCAP NVDATA ws2_32 Iphlpapi ${OpENer_CIP_OBJECTS} )
+endif()
 
 # Add additional CIP Objects
 string(COMPARE NOTEQUAL "${OpENer_ADD_CIP_OBJECTS}" "" OpENer_HAS_ADDITIONAL_OBJECT )