`\src\notation\view
\src\engraving\libmscore`
for Musescore.
I have a file in \view\noteinputcursor.cpp
that I need to do some math in, but the numbers need to come from \libmscore\stringdata.cpp
- i want the cursor i'm working with the know what fret I'm on to know how to highlight it, say a wide cursor or a narrow one.
what's a good way to reference that, and it has to work on anyone else that compiles it in the world too without adding stuff in environment or dependencies. the simplest way for everyone. ideally nobody outside of me (and those who review my hopeful future code) should even notice it.
tried just doing
#include stringdata.h
but then realized it wouldn't work since they're in different folders and the compiler only works downstream not upstream/sidestream/parallel stream etc.
CodePudding user response:
use cmake to organize your code. cmake is a makefile generation tool. it generates makefiles i.e. MinGW Makefiles, Visual Studio Projects, etc. it use a file to describe how your projects' code organised, and make linking program compile and link your dependicies easily.
for example, this is a project, i wrote it to learn OpenGL. It is easy to link libraries i.e. glfw easily.
cmake_minimum_required ( VERSION 3.15 )
project ( Freecraft )
set ( PRJ_SRC_LIST ) #all sources in the project
set ( PRJ_LIBRARIES ) #all libraries in the project
set ( PRJ_INCLUDE_DIRS )#all headers in the project
#set ( GLFW "d:/software/GLFW3" )
file ( GLOB_RECURSE root_header_files "${PROJECT_SOURCE_DIR}/src/*.h" "${PROJECT_SOURCE_DIR}/src/*.hpp" )
file ( GLOB_RECURSE root_src_files "${PROJECT_SOURCE_DIR}/src/*.cpp" "${PROJECT_SOURCE_DIR}/src/*.c" )
set ( GL_INC "${PROJECT_SOURCE_DIR}/include/" )
set ( GLFW_LIB "${PROJECT_SOURCE_DIR}/lib/glfw3.dll" )
list ( APPEND PRJ_INCLUDE_DIRS . )
list ( APPEND PRJ_INCLUDE_DIRS ${GL_INC} )
#list ( APPEND PRJ_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include/glad/" )
#list ( APPEND PRJ_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include/KHR" )
list ( APPEND PRJ_SRC_LIST ${root_src_files} )
list ( APPEND PRJ_LIBRARIES ${GLFW_LIB} )
add_executable ( ${PROJECT_NAME} ${PRJ_SRC_LIST} )
target_include_directories ( ${PROJECT_NAME}
PRIVATE
${PRJ_INCLUDE_DIRS}
)
target_link_libraries ( ${PROJECT_NAME}
PRIVATE
${PRJ_LIBRARIES}
)
go to cmake.org for more details.
CodePudding user response:
i found a proper way to do it within c , natively, without using cmake or any other.... way.
Referencing a cpp/h file in different location
just do
#include "../LowestSharedFolder/KeepGoingTill/YouGetToYour/NowReferencedFile.cpp"
must be 2 or 1 period before. cannot be 3.
.../folder/ bad
../folder/ good
./folder/ good
..\back\slash\folders\are\bad.cpp