Skip to content

Commit

Permalink
Always overwrite nCine_DIR and CMAKE_PREFIX_PATH
Browse files Browse the repository at this point in the history
- Fix some method invocations that have a string object as parameter
- README file updated with the new overwrite policy for the two variables
  • Loading branch information
encelo committed Oct 17, 2023
1 parent b2bd20e commit f03a451
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ You can specify the directory that will be passed as `nCine_DIR` to game project

ncline set -ncine-dir /path/to/nCine-build

If the option is not already specified then it is automatically set after a successful compilation of the engine.
The option is automatically set after each successful compilation or download of the engine.

If you need to specify additional CMake arguments when configuring the engine compilation you can use the `-cmake-args <args>` option:

Expand All @@ -78,7 +78,7 @@ On Windows you can also pass the `-vs2017` and `-vs2019` to choose between the V
If left unspecified the default would be `-vs2019`.

If you need to specify a `CMAKE_PREFIX_PATH` when configuring the engine compilation you can use the `-prefix-path <path>` option.
If the option is not already specified on Linux then it is automatically set after a successful compilation of the libraries.
The option is automatically set after each successful compilation or download of the libraries.

#### Android section

Expand Down
8 changes: 4 additions & 4 deletions src/BuildMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ void buildLibraries(CMakeCommand &cmake, const Settings &settings)
hasBuilt = cmake.build(buildDir.data());

#if !defined(_WIN32) && !defined(__APPLE__)
if (hasBuilt && config().hasCMakePrefixPath() == false)
if (hasBuilt) // Overwrite `CMAKE_PREFIX_PATH` variable in any case
{
std::string absolutePath = fs::currentDir();
absolutePath = fs::joinPath(absolutePath, Helpers::nCineExternalDir());

if (fs::isDirectory(absolutePath.data()))
{
config().setCMakePrefixPath(absolutePath.data());
config().setCMakePrefixPath(absolutePath);
config().save();
Helpers::info("Set 'CMAKE_PREFIX_PATH' CMake variable to: ", absolutePath.data());
}
Expand Down Expand Up @@ -75,13 +75,13 @@ void buildEngine(CMakeCommand &cmake, const Settings &settings)
else
hasBuilt = cmake.build(buildDir.data());

if (hasBuilt && config().hasEngineDir() == false)
if (hasBuilt) // Overwrite `nCine_DIR` variable in any case
{
std::string absolutePath = fs::currentDir();
absolutePath = fs::joinPath(absolutePath, buildDir);
if (fs::isDirectory(absolutePath.data()))
{
config().setEngineDir(absolutePath.data());
config().setEngineDir(absolutePath);
config().save();
Helpers::info("Set 'nCine_DIR' CMake variable to: ", absolutePath.data());
}
Expand Down
11 changes: 5 additions & 6 deletions src/DownloadMode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,19 +190,18 @@ void downloadLibrariesArtifact(GitCommand &git, CMakeCommand &cmake)
const bool hasExtracted = extractArchiveAndDeleteDir(cmake, archiveFile.data(), Helpers::nCineLibrariesArtifactsSourceDir());

#if !defined(__APPLE__)
if (config().platform() == Configuration::Platform::DESKTOP &&
hasExtracted && config().hasCMakePrefixPath() == false
if (config().platform() == Configuration::Platform::DESKTOP && hasExtracted
#if defined(_WIN32)
&& config().withMinGW()
#endif
)
) // Overwrite `CMAKE_PREFIX_PATH` variable in any case
{
std::string absolutePath = fs::currentDir();
absolutePath = fs::joinPath(absolutePath, Helpers::nCineExternalDir());

if (fs::isDirectory(absolutePath.data()))
{
config().setCMakePrefixPath(absolutePath.data());
config().setCMakePrefixPath(absolutePath);
config().save();
Helpers::info("Set 'CMAKE_PREFIX_PATH' CMake variable to: ", absolutePath.data());
}
Expand Down Expand Up @@ -323,7 +322,7 @@ void downloadEngineArtifact(GitCommand &git, CMakeCommand &cmake)
else
hasExtracted = extractEngineArchive(git, cmake, archiveFile);

if (hasExtracted && config().hasEngineDir() == false)
if (hasExtracted) // Overwrite `nCine_DIR` variable in any case
{
std::string absolutePath = fs::currentDir();
#ifdef _WIN32
Expand Down Expand Up @@ -359,7 +358,7 @@ void downloadEngineArtifact(GitCommand &git, CMakeCommand &cmake)

if (fs::isDirectory(absolutePath.data()))
{
config().setEngineDir(absolutePath.data());
config().setEngineDir(absolutePath);
config().save();
Helpers::info("Set 'nCine_DIR' CMake variable to: ", absolutePath.data());
}
Expand Down

0 comments on commit f03a451

Please sign in to comment.