cppplug's People
cppplug's Issues
Compile errors with Mono2.0 Unity3d
Hi,
Again :-) Hope you are all well !
I used polly for passing a toolchain (repo: https://github.com/ruslo/polly), and changed the path $MONO_ROOT to use Unity3D's Mono 2.0 framework (build environment: Apple)
It triggers the an error due to ManagedCalculator target not being defined. Please see below, the details of the build setup.
CMake Error at tests/ManagedCalculator/CMakeLists.txt:10 (set_property):
set_property could not find TARGET ManagedCalculator. Perhaps it has not
yet been created.
CMake Error at tests/ManagedCalculator/CMakeLists.txt:12 (add_dependencies):
Cannot add target-level dependencies to non-existent target
"ManagedCalculator".
The add_dependencies works for top-level logical targets created by the
add_executable, add_library, or add_custom_target commands. If you want to
add file-level dependencies see the DEPENDS option of the add_custom_target
and add_custom_command commands.
To fix it, i added the following in ./tests/ManagedCalculator/CMakeLists.txt
add_library(${PROJECT_NAME} SHARED ${SRC})
but it triggers a missing dependency target error.
CMake Error at CMakeLists.txt:92 (add_dependencies):
The dependency target "CppPlug.Net" of target "CppPlug" does not exist.
And, after some hacks and tests, too lengthy to explain, I got a series of error related to some mono constants not defined (eg. MONO_DEFAULT_DOMAIN_NAME, MONO_DEFAULT_ASSEMBLY_DIR,...).
My assumption is that Apple MacOSX build env are not covered and tested yet.
3rdparty installed:
- cmake + polly
- unity3d
- visual studio for Mac
- mono 4.6.2
- premake5-osx (compiled from source)
install polly:
git clone --depth=1 https://github.com/ruslo/polly ~/dev/cmake/toolchains/polly
echo "POLLY_ROOT=\"~/dev/cmake/toolchains/polly\"" >> ~/.bash_profile
echo "PATH=$PATH:$POLLY_ROOT/bin" >> ~/.bash_profile
source ~/.bash_profile
default build command*
rm -fR ./_*
cmake -H. -B_builds \
-DMANAGED_PLUGINS_SUPPORT=ON \
-DCREATE_INSTALL=OFF
-DBUILD_TESTS=ON
-DMONO_ROOT=/Volumes/HardDrive/Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Versions/Current
cmake --build _builds/
build command with Polly:
build.py --toolchain=osx-10-12 \
--config Release
--install
--clear
--reconfig
--fwd MANAGED_PLUGINS_SUPPORT=ON \
CREATE_INSTALL=OFF \
BUILD_TESTS=ON \
MONO_ROOT=/Volumes/HardDrive/Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Versions/Current
My changes:
#include_directories("${MONO_ROOT}/include/mono-2.0")
- include_directories("${MONO_ROOT}/share/mono-2.0")
#set(MONO_RUNTIME_DLL "${MONO_ROOT}/bin/monosgen-2.0.dll")
set(MONO_RUNTIME_DLL "${MONO_ROOT}/bin/mono-sgen")
#target_link_libraries(${PROJECT_NAME} "${MONO_ROOT}/lib/monosgen-2.0.lib")
target_link_libraries(${PROJECT_NAME} "${MONO_ROOT}/lib/libmonosgen-2.0.1.dylib")
CMakeLists.txt used:
cmake_minimum_required(VERSION 3.0.2 FATAL_ERROR)
set(CMAKE_CXX_STANDARD 11)
project(CppPlug C CXX)
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
# Check target architecture
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(CppPlug_64_BIT 1)
else()
set(CppPlug_64_BIT 0)
endif()
#
set(CppPlug_VERSION_MAJOR "0")
set(CppPlug_VERSION_MINOR "1")
set(CppPlug_VERSION_PATCH "0")
set(CppPlug_VERSION "${CppPlug_VERSION_MAJOR}.${CppPlug_VERSION_MINOR}.${CppPlug_VERSION_PATCH}")
option(MANAGED_PLUGINS_SUPPORT "If enabled managed plugins will be supported using Mono" OFF)
option(CREATE_INSTALL "Generate installation target" OFF)
option(BUILD_TESTS "Builds the tests" ON)
add_definitions(-DCppPlug_EXPORT_SHARED)
if(MANAGED_PLUGINS_SUPPORT)
set(MONO_ROOT "" CACHE STRING "Path where to find the Mono installation")
if(MONO_ROOT STREQUAL "")
message(FATAL_ERROR "Provide a valid root path for Mono")
endif()
add_definitions(-DSUPPORT_MANAGED)
include_directories("${MONO_ROOT}/share/mono-2.0")
#include_directories("${MONO_ROOT}/include/mono-2.0")
set(MONO_COMPILER_DIR "${MONO_ROOT}/bin")
endif()
file(GLOB SRC "${PROJECT_SOURCE_DIR}/src/*.*")
add_library(${PROJECT_NAME} SHARED ${SRC})
if(WIN32)
set_property(TARGET ${PROJECT_NAME} PROPERTY COMPILE_DEFINITIONS_RELEASE _CRT_SECURE_NO_WARNINGS)
set_property(TARGET ${PROJECT_NAME} PROPERTY COMPILE_DEFINITIONS_DEBUG _CRT_SECURE_NO_WARNINGS)
endif()
if(MANAGED_PLUGINS_SUPPORT)
# mono-sgen
# /Volumes/HardDrive/Applications/Unity/MonoDevelop.app/Contents/Frameworks/Mono.framework/Versions/Current/lib/libmonosgen-2.0.1.dylib
# /monosgen/
set(MONO_RUNTIME_DLL "${MONO_ROOT}/bin/mono-sgen")
#set(MONO_RUNTIME_DLL "${MONO_ROOT}/bin/monosgen-2.0.dll")
target_link_libraries(${PROJECT_NAME} "${MONO_ROOT}/lib/libmonosgen-2.0.1.dylib")
#target_link_libraries(${PROJECT_NAME} "${MONO_ROOT}/lib/monosgen-2.0.lib")
endif()
# Set the output path and properties
set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/Build/CppPlug/lib/Debug" LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/Build/CppPlug/bin/Debug" RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/Build/CppPlug/bin/Debug")
set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/Build/CppPlug/lib/Release" LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/Build/CppPlug/bin/Release" RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/Build/CppPlug/bin/Release")
set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_BINARY_DIR}/Build/CppPlug/lib/MinSizeRel" LIBRARY_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_BINARY_DIR}/Build/CppPlug/bin/MinSizeRel" RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_BINARY_DIR}/Build/CppPlug/bin/MinSizeRel")
set_target_properties(${PROJECT_NAME} PROPERTIES ARCHIVE_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/Build/CppPlug/lib/RelWithDebInfo" LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/Build/CppPlug/bin/RelWithDebInfo" RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/Build/CppPlug/bin/RelWithDebInfo")
set_target_properties(${PROJECT_NAME} PROPERTIES RELEASE_POSTFIX "")
set_target_properties(${PROJECT_NAME} PROPERTIES DEBUG_POSTFIX "")
set_target_properties(${PROJECT_NAME} PROPERTIES MINSIZEREL_POSTFIX "")
set_target_properties(${PROJECT_NAME} PROPERTIES RELWITHDEBINFO_POSTFIX "")
# Include version information in the output
set_target_properties(${PROJECT_NAME} PROPERTIES VERSION ${CppPlug_VERSION})
if(MANAGED_PLUGINS_SUPPORT)
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy "${MONO_RUNTIME_DLL}" "${CMAKE_BINARY_DIR}/Build/CppPlug/bin/$<$<CONFIG:Debug>:Debug>$<$<CONFIG:Release>:Release>$<$<CONFIG:RelWithDebInfo>:RelWithDebInfo>$<$<CONFIG:MinSizeRel>:MinSizeRel>")
endif()
# CMake Error at CMakeLists.txt:102 (add_dependencies):
# The dependency target "CppPlug.Net" of target "CppPlug" does not exist.
if (APPLE)
# Append -fno-common to the compile flags to work around a bug in
# Apple's GCC
get_target_property(CppPlug_CFLAGS ${PROJECT_NAME} COMPILE_FLAGS)
if (NOT CppPlug_CFLAGS)
set(CppPlug_CFLAGS "")
endif()
set_target_properties(${PROJECT_NAME} PROPERTIES
COMPILE_FLAGS "${CppPlug_CFLAGS} -fno-common"
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/CppPlug/lib${LIB_SUFFIX}")
set_target_properties(${PROJECT_NAME} PROPERTIES SOVERSION ${CppPlug_VERSION})
endif()
if(MANAGED_PLUGINS_SUPPORT)
add_subdirectory(src/dotNet)
add_dependencies(${PROJECT_NAME} "CppPlug.Net")
if(WIN32)
if(NOT EXISTS "${PROJECT_SOURCE_DIR}/CppPlugGen/build/CppPlugGen.sln")
message(FATAL_ERROR "CppPlugGen project wans't found. Generate the project using the script inside the CppPlugGen folder")
endif()
if(CppPlug_64_BIT)
else()
set(CppPlug_Net_Bindings "${CMAKE_BINARY_DIR}/Build/CppPlug/bin/")
add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND "${PROJECT_SOURCE_DIR}/CppPlugGen/build/lib/CppPlugGen.exe" "${MONO_COMPILER_DIR}" "${CMAKE_BINARY_DIR}/Build/CppPlug/bin/$<$<CONFIG:Debug>:Debug>$<$<CONFIG:Release>:Release>$<$<CONFIG:RelWithDebInfo>:RelWithDebInfo>$<$<CONFIG:MinSizeRel>:MinSizeRel>/" WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}")
endif()
endif()
endif()
if(BUILD_TESTS)
add_subdirectory(tests/Calculator)
add_subdirectory(tests/StandardCalculator)
add_subdirectory(tests/AdvancedCalculator)
if(MANAGED_PLUGINS_SUPPORT)
add_subdirectory(tests/ManagedCalculator)
endif()
endif()
if(CREATE_INSTALL)
if(MANAGED_PLUGINS_SUPPORT)
install(FILES "${MONO_RUNTIME_DLL}" DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
endif()
install(DIRECTORY "${PROJECT_SOURCE_DIR}/src/" DESTINATION "include" PATTERN "*.cpp" EXCLUDE PATTERN "dotNet" EXCLUDE)
if(MANAGED_PLUGINS_SUPPORT)
install(FILES "${CMAKE_BINARY_DIR}/Build/CppPlug/bin/$<$<CONFIG:Debug>:Debug>$<$<CONFIG:Release>:Release>$<$<CONFIG:RelWithDebInfo>:RelWithDebInfo>$<$<CONFIG:MinSizeRel>:MinSizeRel>/CppPlug.Net.dll" DESTINATION "${CMAKE_INSTALL_PREFIX}/bin")
endif()
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION "bin/"
LIBRARY DESTINATION "bin/"
ARCHIVE DESTINATION "lib/")
endif()
It would be awesome to get it work on Apple machines and to hook additional task to CppPlug as I mentioned in this issue.
Have a great week end ! :--)
Richard
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.