Skip to content

Commit

Permalink
Merge pull request #74 from Microsoft/parallel-builds
Browse files Browse the repository at this point in the history
Fix: avoid parallel builds breaking where manually-copied files were colliding
  • Loading branch information
timhutton authored Jun 13, 2016
2 parents 8f5de68 + 1585249 commit 1635dad
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 39 deletions.
12 changes: 7 additions & 5 deletions Malmo/src/CSharpWrapper/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
54 changes: 20 additions & 34 deletions Malmo/test/CSharpTests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,37 +19,23 @@ if ( ALE_FOUND )
)
endif()

if( WIN32 )
set( TEST_FOLDER ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG> )
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=$<TARGET_FILE_DIR:MalmoNETNative>
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 $<TARGET_FILE_DIR:MalmoNETNative>/MalmoNET.dll .
COMMAND cp
ARGS $<TARGET_FILE_DIR:MalmoNETNative>/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()
Expand All @@ -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()

0 comments on commit 1635dad

Please sign in to comment.