From 46257ab7cf017f0f35a2025257ad5f45a9e985f0 Mon Sep 17 00:00:00 2001 From: dec05eba Date: Wed, 3 Jan 2018 18:34:29 +0100 Subject: CMake: Add all generated library files as dependency instead of the last modified one --- README.md | 1 - project.conf | 1 + src/CmakeModule.cpp | 64 ++++++++++++++++++++--------------------------------- 3 files changed, 25 insertions(+), 41 deletions(-) diff --git a/README.md b/README.md index 29a1685..08cd27a 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,6 @@ lib = "windows/x86/static/release" [config.win64.static.debug] lib = "windows/x64/static/debug" -# cmake building is currrently not implemented, but it is intended to work like this [cmake] dir = "." args = ["ENTITYX_RUN_BENCHMARKS=0"] diff --git a/project.conf b/project.conf index 93665a5..2c3f04c 100644 --- a/project.conf +++ b/project.conf @@ -10,3 +10,4 @@ ignore_dirs = ["cmake"] [dependencies] libcurl = "7.57.0" libarchive = "3.3.2" +rapidjson = "1.1.0" diff --git a/src/CmakeModule.cpp b/src/CmakeModule.cpp index e05a65f..7d5509c 100644 --- a/src/CmakeModule.cpp +++ b/src/CmakeModule.cpp @@ -133,55 +133,39 @@ namespace sibs if(config.getPackageType() != PackageType::EXECUTABLE) { - FileString libFile; - u64 libFileLastModified = 0; - string buildPathUtf8 = toUtf8(buildPath); - nprintf("Searching for library generate by cmake in build path: %s\n", buildPathUtf8.c_str()); - walkDirFiles(buildPath.c_str(), [&libFile, &libFileLastModified](tinydir_file *file) + nprintf("Searching for libraries generate by cmake in build path: %s\n", buildPathUtf8.c_str()); + walkDirFiles(buildPath.c_str(), + [&config, &staticLinkerFlagCallbackFunc, &dynamicLinkerFlagCallbackFunc](tinydir_file *file) { if(_tinydir_strcmp(file->extension, CONFIG_DYNAMIC_LIB_FILE_EXTENSION) == 0) { - u32 fileLastModified = getFileLastModifiedTime(file->path); - if(fileLastModified > libFileLastModified) + string libFileUtf8 = toUtf8(file->path); + nprintf("Library generated by cmake: %s\n", libFileUtf8.c_str()); + + switch(config.getPackageType()) { - libFileLastModified = fileLastModified; - libFile = file->path; + case PackageType::STATIC: + { + string libFileCmd = "\""; + libFileCmd += libFileUtf8; + libFileCmd += "\""; + staticLinkerFlagCallbackFunc(libFileCmd); + break; + } + case PackageType::DYNAMIC: + case PackageType::LIBRARY: + { + string libFileCmd = "\""; + libFileCmd += libFileUtf8; + libFileCmd += "\""; + dynamicLinkerFlagCallbackFunc(libFileCmd); + break; + } } } }); - if(libFileLastModified == 0) - { - string errMsg = "Package "; - errMsg += config.getPackageName(); - errMsg += " was built using cmake but no generated library was found"; - return Result::Err(errMsg); - } - string libFileUtf8 = toUtf8(libFile); - nprintf("Library generated by cmake: %s\n", libFileUtf8.c_str()); - - switch(config.getPackageType()) - { - case PackageType::STATIC: - { - string libFileCmd = "\""; - libFileCmd += libFileUtf8; - libFileCmd += "\""; - staticLinkerFlagCallbackFunc(libFileCmd); - break; - } - case PackageType::DYNAMIC: - case PackageType::LIBRARY: - { - string libFileCmd = "\""; - libFileCmd += libFileUtf8; - libFileCmd += "\""; - dynamicLinkerFlagCallbackFunc(libFileCmd); - break; - } - } - // TODO: Clean this up. The below code is indentical to code in Ninja.cpp....... string projectPathUtf8 = toUtf8(config.getProjectPath()); for (const string &globalIncludeDir : config.getGlobalIncludeDirs()) -- cgit v1.2.3