CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT("dotnet-tools") MESSAGE("CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}") INCLUDE(FindPkgConfig) PKG_CHECK_MODULES(${PROJECT_NAME} REQUIRED aul pkgmgr-info pkgmgr-installer dlog ecore bundle dlog liblaunchpad glib-2.0 libsmack capi-appfw-app-common storage jsoncpp openssl sqlite3) FOREACH(flag ${${PROJECT_NAME}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) IF(DEFINED LAUNCHER_CONFIG_PATH) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DLAUNCHER_CONFIG_PATH=${LAUNCHER_CONFIG_PATH}") ENDIF(DEFINED LAUNCHER_CONFIG_PATH) IF(DEFINED DEVICE_API_DIR) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DDEVICE_API_DIR=${DEVICE_API_DIR}") ENDIF(DEFINED DEVICE_API_DIR) IF(DEFINED RUNTIME_DIR) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DRUNTIME_DIR=${RUNTIME_DIR}") ENDIF(DEFINED RUNTIME_DIR) IF(DEFINED CROSSGEN_PATH) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DCROSSGEN_PATH=${CROSSGEN_PATH}") ENDIF(DEFINED CROSSGEN_PATH) IF(DEFINED VERSION) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DVERSION=${VERSION}") ENDIF(DEFINED VERSION) IF(DEFINED NATIVE_LIB_DIR) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DNATIVE_LIB_DIR=${NATIVE_LIB_DIR}") ENDIF(DEFINED NATIVE_LIB_DIR) IF(DEFINED TAC_DIR) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DTAC_DIR=${TAC_DIR}") ENDIF(DEFINED TAC_DIR) IF(DEFINED USE_DEFAULT_BASE_ADDR) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DUSE_DEFAULT_BASE_ADDR") ENDIF(DEFINED USE_DEFAULT_BASE_ADDR) IF(DEFINED UNIQUE_DEFAULT_BASE_ADDR_SUPPORT) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DUNIQUE_DEFAULT_BASE_ADDR_SUPPORT") ENDIF(DEFINED UNIQUE_DEFAULT_BASE_ADDR_SUPPORT) IF(DEFINED SYSTEM_BASE_FILE) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DSYSTEM_BASE_FILE=${SYSTEM_BASE_FILE}") ENDIF(DEFINED SYSTEM_BASE_FILE) IF(DEFINED DEFAULT_BASE_ADDR_START) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DDEFAULT_BASE_ADDR_START=${DEFAULT_BASE_ADDR_START}") ENDIF(DEFINED DEFAULT_BASE_ADDR_START) OPTION(NOT_USE_FUNCTION "Remove build warning" OFF) IF(NOT_USE_FUNCTION) ADD_DEFINITIONS("-DNOT_USE_FUNCTION") ENDIF(NOT_USE_FUNCTION) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -pthread -std=c++11 -ggdb") #SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden") #SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fPIE") SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fdata-sections -ffunction-sections") SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -D_FILE_OFFSET_BITS=64") #SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -DLAUNCHING_TIME_MEASURE") IF(ASAN_ENABLED) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fno-omit-frame-pointer -fsanitize=address") ELSE(ASAN_ENABLED) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,-zdefs") SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,--no-as-needed") SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wl,--gc-sections") ENDIF(ASAN_ENABLED) SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") SET(CMAKE_CXX_FLAGS_DEBUG "-O2 -g") SET(CMAKE_CXX_FLAGS_RELEASE "-O2") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") #SET(${PROJECT_NAME}_LDFLAGS ${${PROJECT_NAME}_LDFLAGS} "-pie") INCLUDE_DIRECTORIES(inc launcher util) SET(DOTNET_LAUNCHER_UTIL "dotnet_launcher_util") SET(${DOTNET_LAUNCHER_UTIL}_SOURCE_FILES util/utils.cc util/plugin_manager.cc util/path_manager.cc util/log_manager.cc util/db_manager.cc ) ADD_LIBRARY(${DOTNET_LAUNCHER_UTIL} SHARED ${${DOTNET_LAUNCHER_UTIL}_SOURCE_FILES}) SET_TARGET_PROPERTIES(${DOTNET_LAUNCHER_UTIL} PROPERTIES COMPILE_FLAGS "-fPIC") TARGET_LINK_LIBRARIES(${DOTNET_LAUNCHER_UTIL} ${${PROJECT_NAME}_LDFLAGS} "-ldl" boost_filesystem boost_system) SET(DOTNET_LAUNCHER "dotnet-launcher") SET(${DOTNET_LAUNCHER}_SOURCE_FILES launcher/main.cc launcher/injection.cc launcher/launcher.cc launcher/dotnet/dotnet_launcher.cc ) ADD_EXECUTABLE(${DOTNET_LAUNCHER} ${${DOTNET_LAUNCHER}_SOURCE_FILES}) SET_TARGET_PROPERTIES(${DOTNET_LAUNCHER} PROPERTIES COMPILE_FLAGS "-fPIE") TARGET_LINK_LIBRARIES(${DOTNET_LAUNCHER} ${${PROJECT_NAME}_LDFLAGS} "-pie -ldl -lpthread" aul ${DOTNET_LAUNCHER_UTIL}) SET_TARGET_PROPERTIES(${DOTNET_LAUNCHER} PROPERTIES SKIP_BUILD_RPATH TRUE ) # remove rpath option that is automatically generated by cmake. SET(NI_COMMON "ni_common") SET(${NI_COMMON}_SOURCE_FILES tool/ni_common.cc ) ADD_LIBRARY(${NI_COMMON} SHARED ${${NI_COMMON}_SOURCE_FILES}) SET_TARGET_PROPERTIES(${NI_COMMON} PROPERTIES COMPILE_FLAGS "-fPIC") TARGET_LINK_LIBRARIES(${NI_COMMON} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL}) SET(NITOOL "nitool") SET(${NITOOL}_SOURCE_FILES tool/nitool.cc ) ADD_EXECUTABLE(${NITOOL} ${${NITOOL}_SOURCE_FILES}) SET_TARGET_PROPERTIES(${NITOOL} PROPERTIES COMPILE_FLAGS "-fPIE") TARGET_LINK_LIBRARIES(${NITOOL} ${${PROJECT_NAME}_LDFLAGS} "-pie" ${DOTNET_LAUNCHER_UTIL} ${NI_COMMON}) SET(TPATOOL "tpatool") SET(${TPATOOL}_SOURCE_FILES tool/tpatool.cc ) ADD_EXECUTABLE(${TPATOOL} ${${TPATOOL}_SOURCE_FILES}) SET_TARGET_PROPERTIES(${TPATOOL} PROPERTIES COMPILE_FLAGS "-fPIE") TARGET_LINK_LIBRARIES(${TPATOOL} ${${PROJECT_NAME}_LDFLAGS} "-pie" ${DOTNET_LAUNCHER_UTIL}) SET(TACTOOL "tactool") SET(${TACTOOL}_SOURCE_FILES tool/tactool.cc ) ADD_EXECUTABLE(${TACTOOL} ${${TACTOOL}_SOURCE_FILES}) SET_TARGET_PROPERTIES(${TACTOOL} PROPERTIES COMPILE_FLAGS "-fPIE") TARGET_LINK_LIBRARIES(${TACTOOL} ${${PROJECT_NAME}_LDFLAGS} "-pie" ${DOTNET_LAUNCHER_UTIL} ${NI_COMMON}) #SET(INSTALLER_PLUGIN "ui-application") #SET(${INSTALLER_PLUGIN}_SOURCE_FILES # util/utils.cc # installer-plugin/common.cc # installer-plugin/ui-application.cc #) #ADD_LIBRARY(${INSTALLER_PLUGIN} SHARED ${${INSTALLER_PLUGIN}_SOURCE_FILES}) #SET_TARGET_PROPERTIES(${INSTALLER_PLUGIN} PROPERTIES COMPILE_FLAGS "-fPIC") #TARGET_LINK_LIBRARIES(${INSTALLER_PLUGIN} ${${PROJECT_NAME}_LDFLAGS}) SET(PREFER_DOTNET_AOT_PLUGIN "prefer_dotnet_aot_plugin") SET(${PREFER_DOTNET_AOT_PLUGIN}_SOURCE_FILES installer-plugin/prefer_dotnet_aot_plugin.cc ) ADD_LIBRARY(${PREFER_DOTNET_AOT_PLUGIN} SHARED ${${PREFER_DOTNET_AOT_PLUGIN}_SOURCE_FILES}) SET_TARGET_PROPERTIES(${PREFER_DOTNET_AOT_PLUGIN} PROPERTIES COMPILE_FLAGS "-fPIC") TARGET_LINK_LIBRARIES(${PREFER_DOTNET_AOT_PLUGIN} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL} ${NI_COMMON}) SET(PREFER_NUGET_CACHE_PLUGIN "prefer_nuget_cache_plugin") SET(${PREFER_NUGET_CACHE_PLUGIN}_SOURCE_FILES installer-plugin/prefer_nuget_cache_plugin.cc ) ADD_LIBRARY(${PREFER_NUGET_CACHE_PLUGIN} SHARED ${${PREFER_NUGET_CACHE_PLUGIN}_SOURCE_FILES}) SET_TARGET_PROPERTIES(${PREFER_NUGET_CACHE_PLUGIN} PROPERTIES COMPILE_FLAGS "-fPIC") TARGET_LINK_LIBRARIES(${PREFER_NUGET_CACHE_PLUGIN} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL} ${NI_COMMON}) CONFIGURE_FILE(dotnet-launcher.pc.in dotnet-launcher.pc @ONLY) INSTALL(TARGETS ${DOTNET_LAUNCHER_UTIL} DESTINATION ${LIBDIR}) INSTALL(TARGETS ${DOTNET_LAUNCHER} DESTINATION ${BINDIR}) INSTALL(TARGETS ${NI_COMMON} DESTINATION ${LIBDIR}) INSTALL(TARGETS ${NITOOL} DESTINATION ${BINDIR}) INSTALL(TARGETS ${TPATOOL} DESTINATION ${BINDIR}) INSTALL(TARGETS ${TACTOOL} DESTINATION ${BINDIR}) #INSTALL(TARGETS ${INSTALLER_PLUGIN} DESTINATION ${INSTALL_PLUGIN_DIR}) INSTALL(TARGETS ${PREFER_DOTNET_AOT_PLUGIN} DESTINATION ${INSTALL_MDPLUGIN_DIR}) INSTALL(TARGETS ${PREFER_NUGET_CACHE_PLUGIN} DESTINATION ${INSTALL_MDPLUGIN_DIR}) INSTALL(FILES dotnet.loader DESTINATION ${LOADERDIR}) INSTALL(FILES dotnet.launcher DESTINATION ${LOADERDIR}) INSTALL(FILES dotnet.debugger DESTINATION ${LOADERDIR}) INSTALL(FILES inc/coreclr_host.h DESTINATION ${INCLUDEDIR}) INSTALL(FILES inc/dotnet_launcher_plugin.h DESTINATION ${INCLUDEDIR}) INSTALL(FILES inc/ni_common.h DESTINATION ${INCLUDEDIR}) INSTALL(FILES ../dotnet-launcher.pc DESTINATION ${LIBDIR}/pkgconfig) INSTALL(FILES dotnet-launcher.info DESTINATION /usr/share/parser-plugins)