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 ecore bundle dlog liblaunchpad glib-2.0 libsmack capi-appfw-app-common storage jsoncpp openssl1.1 sqlite3) FOREACH(flag ${${PROJECT_NAME}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) SET(target_hydra dotnet_hydra_launcher) PKG_CHECK_MODULES(${target_hydra} REQUIRED liblaunchpad-hydra) FOREACH(flag ${${target_hydra}_CFLAGS}) SET(EXTRA_CFLAGS_HYDRA "${EXTRA_CFLAGS_HYDRA} ${flag}") ENDFOREACH(flag) IF(DEFINED LAUNCHER_CONFIG_PATH) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -DLAUNCHER_CONFIG_PATH=${LAUNCHER_CONFIG_PATH}") ENDIF(DEFINED LAUNCHER_CONFIG_PATH) IF(DEFINED DEVICE_API_DIR) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -DDEVICE_API_DIR=${DEVICE_API_DIR}") ENDIF(DEFINED DEVICE_API_DIR) IF(DEFINED RUNTIME_DIR) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -DRUNTIME_DIR=${RUNTIME_DIR}") ENDIF(DEFINED RUNTIME_DIR) IF(DEFINED FRAMEWORK_DIR) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -DFRAMEWORK_DIR=${FRAMEWORK_DIR}") ENDIF(DEFINED FRAMEWORK_DIR) IF(DEFINED CROSSGEN_PATH) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -DCROSSGEN_PATH=${CROSSGEN_PATH}") ENDIF(DEFINED CROSSGEN_PATH) IF(DEFINED VERSION) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -DVERSION=${VERSION}") ENDIF(DEFINED VERSION) IF(DEFINED NATIVE_LIB_DIR) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -DNATIVE_LIB_DIR=${NATIVE_LIB_DIR}") ENDIF(DEFINED NATIVE_LIB_DIR) IF(DEFINED TAC_DIR) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -DTAC_DIR=${TAC_DIR}") ENDIF(DEFINED TAC_DIR) IF(DEFINED USE_DEFAULT_BASE_ADDR) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -DUSE_DEFAULT_BASE_ADDR") ENDIF(DEFINED USE_DEFAULT_BASE_ADDR) IF(DEFINED UNIQUE_DEFAULT_BASE_ADDR_SUPPORT) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -DUNIQUE_DEFAULT_BASE_ADDR_SUPPORT") ENDIF(DEFINED UNIQUE_DEFAULT_BASE_ADDR_SUPPORT) IF(DEFINED SYSTEM_BASE_FILE) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -DSYSTEM_BASE_FILE=${SYSTEM_BASE_FILE}") ENDIF(DEFINED SYSTEM_BASE_FILE) IF(DEFINED DEFAULT_BASE_ADDR_START) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -DDEFAULT_BASE_ADDR_START=${DEFAULT_BASE_ADDR_START}") ENDIF(DEFINED DEFAULT_BASE_ADDR_START) ADD_DEFINITIONS(-DLOADERDIR="${LOADERDIR}") OPTION(NOT_USE_FUNCTION "Remove build warning" OFF) IF(NOT_USE_FUNCTION) ADD_DEFINITIONS("-DNOT_USE_FUNCTION") ENDIF(NOT_USE_FUNCTION) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -pthread -std=c++11 -ggdb") #SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -fvisibility=hidden") #SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -fPIE") SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -fdata-sections -ffunction-sections") SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -D_FILE_OFFSET_BITS=64") #SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -DLAUNCHING_TIME_MEASURE") IF(ASAN_ENABLED) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -fno-omit-frame-pointer -fsanitize=address") ELSE(ASAN_ENABLED) SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -Wl,-zdefs") SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -Wl,--no-as-needed") SET(EXTRA_CFLAGS_COMMON "${EXTRA_CFLAGS_COMMON} -Wl,--gc-sections") ENDIF(ASAN_ENABLED) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${EXTRA_CFLAGS_COMMON}") SET(EXTRA_CFLAGS_EXE "${EXTRA_CFLAGS} -fPIE") SET(EXTRA_CFLAGS_LIB "${EXTRA_CFLAGS} -fPIC -Wl,-z,relro") SET(EXTRA_CFLAGS_HYDRA "${EXTRA_CFLAGS_HYDRA} ${EXTRA_CFLAGS_COMMON}") SET(EXTRA_CFLAGS_HYDRA "${EXTRA_CFLAGS_HYDRA} -fPIE") SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS}") #SET(CMAKE_CXX_FLAGS_DEBUG "-O2 -g") #SET(CMAKE_CXX_FLAGS_RELEASE "-O2") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed") 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 ) ADD_LIBRARY(${DOTNET_LAUNCHER_UTIL} SHARED ${${DOTNET_LAUNCHER_UTIL}_SOURCE_FILES}) SET_TARGET_PROPERTIES(${DOTNET_LAUNCHER_UTIL} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_LIB}) 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 ${EXTRA_CFLAGS_EXE}) 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(DOTNET_HYDRA_LAUNCHER "dotnet-hydra-launcher") SET(${DOTNET_HYDRA_LAUNCHER}_SOURCE_FILES hydra/hydra_main.cc ) ADD_EXECUTABLE(${DOTNET_HYDRA_LAUNCHER} ${${DOTNET_HYDRA_LAUNCHER}_SOURCE_FILES}) TARGET_LINK_LIBRARIES(${DOTNET_HYDRA_LAUNCHER} ${${target_hydra}_LDFLAGS} "-pie -ldl") SET_TARGET_PROPERTIES(${DOTNET_HYDRA_LAUNCHER} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_HYDRA}) SET_TARGET_PROPERTIES(${DOTNET_HYDRA_LAUNCHER} PROPERTIES SKIP_BUILD_RPATH TRUE ) # remove rpath option that is automatically generated by cmake. SET(TAC_COMMON "tac_common") SET(${TAC_COMMON}_SOURCE_FILES tool/tac_common.cc util/db_manager.cc ) ADD_LIBRARY(${TAC_COMMON} SHARED ${${TAC_COMMON}_SOURCE_FILES}) SET_TARGET_PROPERTIES(${TAC_COMMON} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_LIB}) TARGET_LINK_LIBRARIES(${TAC_COMMON} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL}) 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 ${EXTRA_CFLAGS_LIB}) TARGET_LINK_LIBRARIES(${NI_COMMON} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL} ${TAC_COMMON}) SET(NITOOL "nitool") SET(${NITOOL}_SOURCE_FILES tool/nitool.cc ) ADD_EXECUTABLE(${NITOOL} ${${NITOOL}_SOURCE_FILES}) SET_TARGET_PROPERTIES(${NITOOL} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_EXE}) 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 ${EXTRA_CFLAGS_EXE}) TARGET_LINK_LIBRARIES(${TPATOOL} ${${PROJECT_NAME}_LDFLAGS} "-pie" ${DOTNET_LAUNCHER_UTIL}) SET(DOTNETTOOL "dotnettool") SET(${DOTNETTOOL}_SOURCE_FILES tool/dotnettool.cc ) ADD_EXECUTABLE(${DOTNETTOOL} ${${DOTNETTOOL}_SOURCE_FILES}) SET_TARGET_PROPERTIES(${DOTNETTOOL} PROPERTIES COMPILE_FLAGS ${EXTRA_CFLAGS_EXE}) TARGET_LINK_LIBRARIES(${DOTNETTOOL} ${${PROJECT_NAME}_LDFLAGS} "-pie" ${DOTNET_LAUNCHER_UTIL} ${NI_COMMON}) 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 ${EXTRA_CFLAGS_LIB}) 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 ${EXTRA_CFLAGS_LIB}) TARGET_LINK_LIBRARIES(${PREFER_NUGET_CACHE_PLUGIN} ${${PROJECT_NAME}_LDFLAGS} ${DOTNET_LAUNCHER_UTIL} ${TAC_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 ${DOTNET_HYDRA_LAUNCHER} DESTINATION ${BINDIR}) INSTALL(TARGETS ${TAC_COMMON} DESTINATION ${LIBDIR}) INSTALL(TARGETS ${NI_COMMON} DESTINATION ${LIBDIR}) INSTALL(TARGETS ${NITOOL} DESTINATION ${BINDIR}) INSTALL(TARGETS ${TPATOOL} DESTINATION ${BINDIR}) INSTALL(TARGETS ${DOTNETTOOL} DESTINATION ${BINDIR}) 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 inc/tac_common.h DESTINATION ${INCLUDEDIR}) INSTALL(FILES ../dotnet-launcher.pc DESTINATION ${LIBDIR}/pkgconfig) INSTALL(FILES dotnet-launcher.info DESTINATION /usr/share/parser-plugins) INSTALL(FILES dotnet.preload.list DESTINATION ${LOADERDIR})