I have been working on something similar like this. I am working on a project which follows model driven approach in c++ using ecore, uml metamodel. I was looking for a way to profile c++ codes for possible optimizations. Th project uses cmake and gradle for build process. I wanted to use visual studio profiler as it supports cmake configuration. I created a user-defined CMakefiles.txt in the root folder so that it can traverse through all subdirectories.
but its not working. The cmake configuartion works but while building solution or such, I dont know what to do. It builds a solution like MDE4CPP.sln in the project root. But then when I configure and start performance profiler on .exe files, it doesnt show any data. Any suggestions?
# Set the minimum required version of CMake
cmake_minimum_required(VERSION 3.10)
# Set the project name
project(MDE4CPP)
# Set the C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Recursively find all CMakeLists.txt files in subdirectories
# This will search in src and userProjects folders
file(GLOB_RECURSE all_subdirectories
RELATIVE ${CMAKE_SOURCE_DIR}
${CMAKE_SOURCE_DIR}/src/*
${CMAKE_SOURCE_DIR}/userProjects/*
)
# Loop through the found subdirectories and add them as subdirectories
foreach(subdir ${all_subdirectories})
# Create an absolute path to the subdirectory
set(abs_subdir "${CMAKE_SOURCE_DIR}/${subdir}")
# Check if a CMakeLists.txt file exists in the subdirectory
if(EXISTS ${abs_subdir}/CMakeLists.txt)
message(STATUS "Adding subdirectory: ${abs_subdir}")
add_subdirectory(${abs_subdir})
endif()
endforeach()