diff --git a/Malmo/src/CSharpWrapper/CMakeLists.txt b/Malmo/src/CSharpWrapper/CMakeLists.txt index f6a339ae0..3c4ccbc68 100755 --- a/Malmo/src/CSharpWrapper/CMakeLists.txt +++ b/Malmo/src/CSharpWrapper/CMakeLists.txt @@ -44,11 +44,13 @@ SWIG_ADD_MODULE(MalmoNETNative csharp MalmoNETNative.i ) INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}) SWIG_LINK_LIBRARIES(${SWIG_MODULE_MalmoNETNative_REAL_NAME} Malmo ) -if ( UNIX ) - set_target_properties(${SWIG_MODULE_MalmoNETNative_REAL_NAME} PROPERTIES SUFFIX ".so") -else ( WIN32 ) - set_target_properties(${SWIG_MODULE_MalmoNETNative_REAL_NAME} PROPERTIES SUFFIX ".dll") -endif( UNIX ) +if( UNIX ) + set_target_properties(${SWIG_MODULE_MalmoNETNative_REAL_NAME} PROPERTIES SUFFIX ".so") + set( MALMO_NET_NATIVE libMalmoNETNative.so CACHE INTERNAL "The MalmoNETNative built library" ) +else() + set_target_properties(${SWIG_MODULE_MalmoNETNative_REAL_NAME} PROPERTIES SUFFIX ".dll") + set( MALMO_NET_NATIVE MalmoNETNative.dll CACHE INTERNAL "The MalmoNETNative built library" ) +endif() # Configure AssemblyInfo.cs configure_file( diff --git a/Malmo/test/CSharpTests/CMakeLists.txt b/Malmo/test/CSharpTests/CMakeLists.txt index 441bb9efd..a75ef1b2a 100755 --- a/Malmo/test/CSharpTests/CMakeLists.txt +++ b/Malmo/test/CSharpTests/CMakeLists.txt @@ -19,37 +19,23 @@ if ( ALE_FOUND ) ) endif() +if( WIN32 ) + set( TEST_FOLDER ${CMAKE_CURRENT_BINARY_DIR}/$ ) +else() + set( TEST_FOLDER ${CMAKE_CURRENT_BINARY_DIR} ) +endif() + foreach( file ${CSHARP_TEST_SOURCES} ) get_filename_component( test_name "${file}" NAME_WE ) set( test_name "CSharpTests_${test_name}" ) - + csharp_add_executable( ${test_name} ${file} "${MALMO_CSHARP_DIR}/MalmoNET.dll" ) add_dependencies( ${test_name} MalmoNET ) - - IF( WIN32 ) - ADD_CUSTOM_COMMAND(TARGET ${test_name} - POST_BUILD - COMMAND set - ARGS malmonet_dir=$ - COMMAND set - ARGS malmonet_dir=%malmonet_dir:/=\\% - COMMAND copy - ARGS /Y %malmonet_dir%\\*.dll . - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$(Configuration)" - COMMENT "Copying dependencies" - ) - ELSE( UNIX ) - ADD_CUSTOM_COMMAND(TARGET ${test_name} - POST_BUILD - COMMAND cp - ARGS $/MalmoNET.dll . - COMMAND cp - ARGS $/libMalmoNETNative.so . - WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$(Configuration)" - COMMENT "Copying dependencies" - ) - ENDIF( WIN32 ) - + + # copy the MalmoNET dynamic libraries to the test build folder + add_custom_command( TARGET ${test_name} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${MALMO_CSHARP_DIR}/MalmoNET.dll ${TEST_FOLDER}/MalmoNET.dll ) + add_custom_command( TARGET ${test_name} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${MALMO_CSHARP_DIR}/${MALMO_NET_NATIVE} ${TEST_FOLDER}/${MALMO_NET_NATIVE} ) + if( NOT WIN32 ) add_test( NAME ${test_name} COMMAND ${CSHARP_INTERPRETER} ${CMAKE_CURRENT_BINARY_DIR}/${test_name}.exe ) else() @@ -60,12 +46,12 @@ endforeach() # copy the schema files to the test build folder foreach( xsd_file ${SCHEMA_FILES} ) -get_filename_component( out_file ${xsd_file} NAME ) -set( out_file ${CMAKE_CURRENT_BINARY_DIR}/${out_file} ) -add_custom_command( - TARGET ${test_name} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different ${xsd_file} ${out_file} -) + get_filename_component( out_file ${xsd_file} NAME ) + set( out_file ${CMAKE_CURRENT_BINARY_DIR}/${out_file} ) + add_custom_command( + TARGET ${test_name} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${xsd_file} ${out_file} + ) endforeach()