Skip to content

Conversation

@bmarques1995
Copy link

Check if target sqlpp23::sqlpp23 exists before creating alias. this is important if you need to recreate the cmake target

Check if target sqlpp23::sqlpp23 exists before creating alias.
@MeanSquaredError
Copy link
Contributor

MeanSquaredError commented Jan 29, 2026

I have a couple of questions about this PR:

  1. Where would the existing target sqlpp23::sqlpp23 come from?

  2. The generated CMake targets file does not check for the existence of the connector-specific targets (sqlpp23::sqlite3, sqlpp23::mysql, sqlpp23::postgresql, etc) before creating these targets so why should we check for sqlpp23::sqlpp23?

@bmarques1995
Copy link
Author

bmarques1995 commented Jan 29, 2026

I have a couple of questions about this PR:

  1. Where would the existing target sqlpp23::sqlpp23 come from?
  2. The generated CMake targets file does not check for the existence of the connector-specific targets (sqlpp23::sqlite3, sqlpp23::mysql, sqlpp23::postgresql, etc) before creating these targets so why should we check for sqlpp23::sqlpp23?

for the first question, I used the target provided by the project (at cmake/configs/Sqlpp23Config.cmake‎)
for the second question, is a weird behavior of cmake, if you rerun the cmake, it tries to create another alias, and this causes a bug.

@MeanSquaredError
Copy link
Contributor

MeanSquaredError commented Jan 29, 2026

for the first question, I used the target provided by the project (at cmake/configs/Sqlpp23Config.cmake‎)

Which target did you use, was it sqlpp23::sqlpp23 ? Ideally it shouldn't cause problems the way it is now.
Did using that target cause any problems? If yes, then can you provide a minimal reproducible example, which allows us to reproduce the problem?

for the second question, is a weird behavior of cmake, if you rerun the cmake, it tries to create another alias, and this causes a bug.

Again, can you provide the minimal reproducible example?

Actually I cannot imagine how and why it would try to create a second alias. I'd like to examine the problem in more detail, because the proposed fix in your PR seems to be masking some other bug.

@MeanSquaredError
Copy link
Contributor

I tried to reproduce the problem, that your PR tries to fix, with the connection pool example. The connection pool example needed a few minor fixes (see the other PR that I just submitted), but otherwise it worked fine.

I tried modifying its CMakeLists.txt and replaced the sqlpp23::core target with sqlpp23::core and it compiled just fine.
Running cmake -B build multiple times works fine, just as expected. Running cmake --build build multiple times also works well. See the console log below:

root@fedora:/usr/local/projects/github/sqlpp23/examples/connection_pool# cmake -B build 
-- The CXX compiler identification is GNU 15.2.1
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE
-- Found PostgreSQL: /usr/lib64/libpq.so (found version "18.0")
-- Configuring done (0.5s)
-- Generating done (0.0s)
-- Build files have been written to: /usr/local/projects/github/sqlpp23/examples/connection_pool/build
root@fedora:/usr/local/projects/github/sqlpp23/examples/connection_pool# cmake -B build 
-- Configuring done (0.0s)
-- Generating done (0.0s)
-- Build files have been written to: /usr/local/projects/github/sqlpp23/examples/connection_pool/build
root@fedora:/usr/local/projects/github/sqlpp23/examples/connection_pool# cmake --build build
[ 25%] Building CXX object CMakeFiles/connection_pool.dir/src/db_connection.cpp.o
[ 50%] Building CXX object CMakeFiles/connection_pool.dir/src/db_global.cpp.o
[ 75%] Building CXX object CMakeFiles/connection_pool.dir/src/main.cpp.o
[100%] Linking CXX executable connection_pool
[100%] Built target connection_pool
root@fedora:/usr/local/projects/github/sqlpp23/examples/connection_pool# cmake --build build
[100%] Built target connection_pool
root@fedora:/usr/local/projects/github/sqlpp23/examples/connection_pool# 

So for me everything works correctly, just as expected. As I said before, I really want to see your minimal reproducible example, because I am unable to reproduce the error on my machine. Just for the record, I am using CMake 4.2.1

@bmarques1995
Copy link
Author

I tried to reproduce the problem, that your PR tries to fix, with the connection pool example. The connection pool example needed a few minor fixes (see the other PR that I just submitted), but otherwise it worked fine.

I tried modifying its CMakeLists.txt and replaced the sqlpp23::core target with sqlpp23::core and it compiled just fine.

Running cmake -B build multiple times works fine, just as expected. Running cmake --build build multiple times also works well. See the console log below:


root@fedora:/usr/local/projects/github/sqlpp23/examples/connection_pool# cmake -B build 

-- The CXX compiler identification is GNU 15.2.1

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Check for working CXX compiler: /usr/bin/c++ - skipped

-- Detecting CXX compile features

-- Detecting CXX compile features - done

-- Performing Test CMAKE_HAVE_LIBC_PTHREAD

-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success

-- Found Threads: TRUE

-- Found PostgreSQL: /usr/lib64/libpq.so (found version "18.0")

-- Configuring done (0.5s)

-- Generating done (0.0s)

-- Build files have been written to: /usr/local/projects/github/sqlpp23/examples/connection_pool/build

root@fedora:/usr/local/projects/github/sqlpp23/examples/connection_pool# cmake -B build 

-- Configuring done (0.0s)

-- Generating done (0.0s)

-- Build files have been written to: /usr/local/projects/github/sqlpp23/examples/connection_pool/build

root@fedora:/usr/local/projects/github/sqlpp23/examples/connection_pool# cmake --build build

[ 25%] Building CXX object CMakeFiles/connection_pool.dir/src/db_connection.cpp.o

[ 50%] Building CXX object CMakeFiles/connection_pool.dir/src/db_global.cpp.o

[ 75%] Building CXX object CMakeFiles/connection_pool.dir/src/main.cpp.o

[100%] Linking CXX executable connection_pool

[100%] Built target connection_pool

root@fedora:/usr/local/projects/github/sqlpp23/examples/connection_pool# cmake --build build

[100%] Built target connection_pool

root@fedora:/usr/local/projects/github/sqlpp23/examples/connection_pool# 

So for me everything works correctly, just as expected. As I said before, I really want to see your minimal reproducible example, because I am unable to reproduce the error on my machine. Just for the record, I am using CMake 4.2.1

I will send a minimum example later

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants