Open DanBennettDev opened 6 years ago
Hi @DanBennettDev
Include and Linker settings should be done in the CMakeLists.txt file for your project rather than manually in the IDE. If you need help with figuring out what to do in there, let me know.
I should include some guidance on this in the documentation as well, though I haven't worked out exactly where/how.
Ok, thanks.
After a bit of fun I seem to have it working -
CMakeLists.txt in the top level solution file - I added this line to the end
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/source/MatsuokaEngine_src)
CMakeLists.txt in the static library directory
cmake_minimum_required(VERSION 3.0)
project(MatsuokaEngine)
aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} MAT_SOURCES)
add_library(MatsuokaEngine STATIC ${MAT_SOURCES})
set(
CMAKE_LIBRARY_OUTPUT_DIRECTORY
../../build/x64/Release
)
CMakeLists.txt in the project for the external that calls the static lib - as per normal min cmakelists file, but with these added:
include_directories(
"${C74_INCLUDES}"
# ADDED BY ME
"../../MatsuokaEngine_src"
)
# ADDED BY ME
target_link_libraries(${PROJECT_NAME} MatsuokaEngine)
Is that close enough to what I ought to do that I haven't stored up pain anywhere? And I'm not sure on how to set up debug and release versions of the library (and use the relevant lib files in the debug and release versions of the external)
This looks perfectly legit on first glance! Glad you got it worked out!
Regarding different configurations for debug vs release, here is a snippet of a CMakeLists.txt
for an object I'm working on right now:
if (CMAKE_BUILD_TYPE STREQUAL "Debug")
add_definitions(
-DDEBUG
)
else ()
add_definitions(
-DNDEBUG
)
endif ()
Both this snippet and the pattern you describe for adding the static lib to the top level are material that I would like to add to the wiki.
Excellent, cheers - v useful :)
Addendum to this in case anyone else is trying to do something similar: I also needed to amend the unit test section at the end of the project cmake file
#############################################################
# UNIT TEST
#############################################################
include(${C74_MIN_API_DIR}/test/min-object-unittest.cmake)
# ADDED BY ME:
target_link_libraries(${PROJECT_NAME} MatsuokaEngine)
excellent point!
On building an individual project in VS2017 I get this periodically, which triggers a CMake rebuild and overwrites my include and linker settings.