well it's not ready as is, but it should be along ...
# windows
s
well it's not ready as is, but it should be along the lines of having
Copy code
set(source_files 
"${CMAKE_CURRENT_BINARY_DIR}/empty_osqueryd_target_source_file.cpp"
${CMAKE_CURRENT_BINARY_DIR}/windows_resources.rc
)
[...]
configure_file(
${CMAKE_SOURCE_DIR}/tools/windows_resources.rc.in
${CMAKE_CURRENT_BINARY_DIR}/windows_resources.rc
@ONLY)
[...]
add_osquery_executable(osqueryd "${source_files}")
here: https://github.com/osquery/osquery/blob/c2fde72fa6c67083b7e56001d51054345977d809/osquery/CMakeLists.txt#L55
t
No Joy 😞 function(generateOsqueryd) # Upstream uses an empty executable that links to a library with a # a main() entry point; try to emulate this. set(source_files "${CMAKE_CURRENT_BINARY_DIR}/empty_osqueryd_target_source_file.cpp" "${CMAKE_CURRENT_BINARY_DIR}/windows_resources.rc" ) generateBuildTimeSourceFile(${source_files} "extern int main(int argc, char* argv[]);") configure_file( ${CMAKE_SOURCE_DIR}/tools/windows_resources.rc.in ${CMAKE_CURRENT_BINARY_DIR}/windows_resources.rc @ONLY) add_osquery_executable(osqueryd "${source_files}") set_target_properties(osqueryd PROPERTIES POSITION_INDEPENDENT_CODE true) target_link_libraries(osqueryd PRIVATE global_cxx_settings osquery_main ) endfunction() C:\temp\osquery\osquery\build\osquery\empty_osqueryd_target_source_file.cpp(1): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int [C:\temp\osquery\osquery\build\osquery\o squeryd.vcxproj] C:\temp\osquery\osquery\build\osquery\empty_osqueryd_target_source_file.cpp(1): error C2059: syntax error: ':' [C:\temp\osquery\osquery\build\osquery\osqueryd.vcxproj] C:\temp\osquery\osquery\build\osquery\empty_osqueryd_target_source_file.cpp(1): error C2059: syntax error: '/' [C:\temp\osquery\osquery\build\osquery\osqueryd.vcxproj]
s
One issue is that you're passing both files to generateBuildTimeSourceFile, only the
empty_osqueryd_target_source_file.cpp
one has to be passed, might want to do something like:
Copy code
[...]
set(source_files  "${CMAKE_CURRENT_BINARY_DIR}/empty_osqueryd_target_source_file.cpp")
generateBuildTimeSourceFile(${source_files} "extern int main(int argc, char* argv[]);")
list(APPEND source_files "${CMAKE_CURRENT_BINARY_DIR}/windows_resources.rc")
[...]
If you check that file in the build folder it will probably not contain
extern int main(int argc, char* argv[]);
, which it should
t
Ya, I forgot to post that the empty_osqueryd_target_source_file.cpp contained the string ../windows_resources.rc not extern int main(int argc, char* argv[]); I got busy trying to figure out how to make it work. I will continue to try different options. Thank you Stefano
I have zero experience with cmake so I'm sure this is completely wrong, but it works 🙂 function(generateOsqueryd) # Upstream uses an empty executable that links to a library with a # a main() entry point; try to emulate this. set(source_files "${CMAKE_CURRENT_BINARY_DIR}/empty_osqueryd_target_source_file.cpp") generateBuildTimeSourceFile(${source_files} "extern int main(int argc, char* argv[]);") list(APPEND source_files "${CMAKE_CURRENT_BINARY_DIR}/windows_resources.rc") list(APPEND source_files "${CMAKE_CURRENT_BINARY_DIR}/tools/wel") set(OSQUERY_PRODUCT_NUMBER 4) set(OSQUERY_PRODUCT_VERSION 0) set(OSQUERY_BUILD_NUMBER 0) configure_file( ${CMAKE_SOURCE_DIR}/tools/windows_resources.rc.in ${CMAKE_CURRENT_BINARY_DIR}/windows_resources.rc @ONLY) file(COPY "${CMAKE_SOURCE_DIR}/tools/wel" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/tools") add_osquery_executable(osqueryd "${source_files}") set_target_properties(osqueryd PROPERTIES POSITION_INDEPENDENT_CODE true) target_link_libraries(osqueryd PRIVATE global_cxx_settings osquery_main ) endfunction()
s
to set the version you like (for instance 4.0.0), you can pass
-DOSQUERY_VERSION="4.0.0"
at the configure phase
t
That doesn't appear to work C:\temp\osquery\osquery\build\osquery\windows_resources.rc(26): error RC2127: version WORDs separated by commas expected [C:\temp\osquery\osquery\build\osquery\osqueryd.vcxproj]
Generated rc file #define VER_FILEVERSION ,,,0 #define VER_FILEVERSION_STR ".0\0" #define VER_PRODUCTVERSION ,,,0 #define VER_PRODUCTVERSION_STR "\0"
s
Yeah I'm sorry, that files has not been touched/corrected after Facebook refactor to Buck and the reintroduction of CMake
It refers to variables that do not exist
t
no worries, I have a workaround. Hopefully sources will be fixed soon. Thx Sefano