1

I am using Clion as IDE of choice as it comes to C++ development. When I create new project on my new Macbook Pro M1 the IDE is running really well. However when I open old cmake project the ide becomes really slow. 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. Same applies for Windows. The problem is only with my Macbook and I believe it has to do something with the architecture. As addition I would like to say that I have Clion installed version Apple Silicon. So I am not using the IDE for the Intel cpus.

Checkout the project main 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 ?

Venelin
  • 2,905
  • 7
  • 53
  • 117

1 Answers1

0

This might be too late but...I've had the same problem with M1 Pro chip 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. 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. 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. I went to their website to download an installer for Apple Silicon and everything is good now. Reinstalling will not affect your projects or other settings as long as files in CLionProjects directory keep unchanged. Hope this helps!

seraphalo
  • 1
  • 2
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 09 '22 at 04:34