简体   繁体   English

Apple Silicon M1/Clion IDE 在旧项目上运行非常缓慢,但在新创建的项目上运行良好。 为什么?

[英]Apple Silicon M1/Clion IDE runs really slow on old projects but runs well on newly created. Why?

I am using Clion as IDE of choice as it comes to C++ development.在 C++ 开发方面,我使用 Clion 作为 IDE。 When I create new project on my new Macbook Pro M1 the IDE is running really well.当我在我的新 Macbook Pro M1 上创建新项目时,IDE 运行得非常好。 However when I open old cmake project the ide becomes really slow.但是,当我打开旧的 cmake 项目时,ide 变得非常慢。 I believe this issue maybe is coming from incorrectly set target.我相信这个问题可能来自错误设定的目标。

Also bare in mind that when I run this project with Clion on my much weaker Linux the IDE there is running as normal.还要记住,当我在我的弱得多的 Linux 上使用 Clion 运行这个项目时,那里的 IDE 正常运行。 Same applies for Windows.同样适用于 Windows。 The problem is only with my Macbook and I believe it has to do something with the architecture.问题只出在我的 Macbook 上,我相信它与架构有关。 As addition I would like to say that I have Clion installed version Apple Silicon.另外我想说我已经安装了 Clion 版本的 Apple Silicon。 So I am not using the IDE for the Intel cpus.所以我没有将 IDE 用于 Intel cpus。

Checkout the project main CmakeLists.txt:签出项目主 CmakeLists.txt:

cmake_minimum_required(VERSION 3.16)

project(Vibranium_Core)

#set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_STANDARD 17)
set(FLATBUFFERS_MAX_PARSING_DEPTH 16)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")

if(EXISTS "${CMAKE_SOURCE_DIR}/.git")
    execute_process(
            COMMAND git rev-list --count HEAD
            WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
            OUTPUT_VARIABLE GIT_VERSION
            OUTPUT_STRIP_TRAILING_WHITESPACE
    )
    execute_process(
            COMMAND git rev-parse --abbrev-ref HEAD
            WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
            OUTPUT_VARIABLE GIT_BRANCH
            OUTPUT_STRIP_TRAILING_WHITESPACE
    )

    execute_process(
            COMMAND git log -1 --format=%h
            WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
            OUTPUT_VARIABLE GIT_COMMIT_HASH
            OUTPUT_STRIP_TRAILING_WHITESPACE
    )
    execute_process(
            COMMAND git --no-pager log -1 --format=%ai
            WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
            OUTPUT_VARIABLE GIT_RELEASED_ON
            OUTPUT_STRIP_TRAILING_WHITESPACE
    )
else(EXISTS "${CMAKE_SOURCE_DIR}/.git")
    set(GIT_BRANCH "")
    set(GIT_COMMIT_HASH "")
endif(EXISTS "${CMAKE_SOURCE_DIR}/.git")

message(STATUS "VibraniumCore current branch: ${GIT_BRANCH}")
message(STATUS "VibraniumCore Version: ${GIT_VERSION}")
message(STATUS "VibraniumCore commit hash: ${GIT_COMMIT_HASH}")
message(STATUS "Released on: ${GIT_RELEASED_ON}")

message(STATUS "Generating version.h")

configure_file(
        ${CMAKE_SOURCE_DIR}/cmake/version.h.in
        ${CMAKE_SOURCE_DIR}/Source/Common/Version.h
)

add_definitions(-DGIT_COMMIT_HASH="${GIT_COMMIT_HASH}")
add_definitions(-DGIT_BRANCH="${GIT_BRANCH}")
add_definitions(-DGIT_VERSION="${GIT_VERSION}")
add_definitions(-DGIT_RELEASED_ON="${GIT_RELEASED_ON}")

#if(NOT Boost_FOUND)
#    message(FATAL_ERROR "Could not find boost!\n** Your distro may provide a binary for Boost e.g. for ubuntu try\n sudo apt install libboost-dev && sudo apt install libboost-all-dev")
#endif()
#include_directories(${Boost_INCLUDE_DIR})

if("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
    message(STATUS "Target is 64 bits")
    if (WIN32)
        set(WINXXBITS Win64)
    endif(WIN32)
else("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")
    message(STATUS "Target is 32 bits")
    if (WIN32)
        set(WINXXBITS Win32)
    endif(WIN32)
endif("${CMAKE_SIZEOF_VOID_P}" EQUAL "8")

# set macro-directory
list(APPEND CMAKE_MODULE_PATH
        "${CMAKE_SOURCE_DIR}/cmake/macros")

find_package(CURL REQUIRED)
find_package(MySQL REQUIRED)
find_package(Flatbuffers REQUIRED
        PATHS /usr/local/flatbuffers)

include_directories(${MYSQL_INCLUDE_DIR})
if(APPLE)
include_directories(/opt/homebrew/include)
endif()
# set default buildoptions and print them
include(cmake/options.cmake)

# Find revision ID and hash of the sourcetree
include(cmake/genrev.cmake)

# print out the results before continuing
include(cmake/showoptions.cmake)

# add dependencies
add_subdirectory(dep)

# add libraries and projects
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Source/Common)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Source/WorldServer)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Source/AuthServer)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/Source/ClientEmulator)
add_subdirectory(Tests)


set_target_properties(VibraniumCoreTests PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(gtest PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(gmock PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(gtest_main PROPERTIES EXCLUDE_FROM_ALL TRUE)
set_target_properties(gmock_main PROPERTIES EXCLUDE_FROM_ALL TRUE)

set_target_properties(
        Common WorldServer AuthServer ClientEmulator
        PROPERTIES
        ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/lib"
        LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/lib"
        RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)

Should I set my target to new ARM architecture and how should I do that ?我应该将目标设置为新的 ARM 架构吗?我应该怎么做?

This might be too late but...I've had the same problem with M1 Pro chip MBP.这可能为时已晚,但是……我对 M1 Pro 芯片 MBP 也有同样的问题。 Reinstalling solved it for me.重新安装为我解决了它。

I used the Migration Assistant App to move all my data from my old MBP to this new one and CLion was installed automatically.我使用迁移助手应用程序将我的所有数据从旧 MBP 移动到这个新 MBP,并自动安装了 CLion。 Everything seemed fine until I started to work on my project on this new machine.一切似乎都很好,直到我开始在这台新机器上处理我的项目。 Things are extremely slow.事情非常缓慢。 Not only editing, but also opening preferences, opening terminal tab and typing things there, and git.不仅可以编辑,还可以打开首选项、打开终端选项卡并在那里输入内容,以及 git。 So I did a bit of research and realized that Migration Assistant was not smart enough to install a correct version of CLion for me or to ask about it.所以我做了一些研究,发现 Migration Assistant 不够聪明,无法为我安装正确版本的 CLion 或询问它。 I went to their website to download an installer for Apple Silicon and everything is good now.我去他们的网站下载了 Apple Silicon 的安装程序,现在一切都很好。 Reinstalling will not affect your projects or other settings as long as files in CLionProjects directory keep unchanged.只要 CLionProjects 目录中的文件保持不变,重新安装不会影响您的项目或其他设置。 Hope this helps!希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM